User Management Guide for Ubuntu – Easy Steps Using the adduser Command

1. Introduction

Ubuntu is an open-source Linux-based operating system widely used for both personal use and cloud server management. User management is one of the fundamental and essential tasks in system administration.
In this article, we will explain how to add new users in Ubuntu using the adduser command, how to remove users, and how to grant administrative privileges. This guide is designed for beginners to intermediate users and provides step-by-step explanations to ensure ease of understanding, even for those unfamiliar with command-line operations.

2. What is User Management in Ubuntu?

User management in Ubuntu refers to adding multiple users to the system and assigning appropriate permissions to each of them. To maintain system security and efficiency, it is crucial to set individual access rights correctly for each user.

In particular, administrators (users with sudo privileges) must manage multiple users properly to ensure the overall security of the system. Here, we introduce a simple and effective user management method using the adduser command.

3. Basics of the adduser Command

The adduser command is a high-level interface for creating users in Ubuntu. Compared to the useradd command, it is more user-friendly, making it easier for beginners to use.

For example, to add a new user named “testuser,” run the following command:

sudo adduser testuser

This command creates the user “testuser” and automatically generates their home directory. Additionally, a prompt appears to set a password and enter optional information such as the full name.

4. Steps to Add a New User Using adduser

  1. Open the terminal (Ctrl + Alt + T).
  2. Enter the following command:
   sudo adduser username

Replace “username” with the desired user name you want to create.

  1. You will be prompted to set a password. Enter a strong password and confirm it by re-entering.
  2. Optional information such as full name and phone number can be entered, but it is not required.
  3. Finally, a confirmation prompt appears. If everything is correct, the new user will be created.

For security reasons, it is recommended to use a strong password. Avoid short or simple passwords, and instead use a combination of letters, numbers, and symbols.

5. Customizing User Creation with adduser

The adduser command allows customization of user creation by using various options. Below are some useful options:

  • -d: Specifies the home directory.
  sudo adduser -d /custom/home username
  • -s: Specifies the login shell.
  sudo adduser -s /bin/zsh username
  • -G: Adds the user to additional groups.
  sudo adduser -G sudo username

By combining these options, you can customize user settings more flexibly.

6. Managing Users with GUI

If you are not comfortable using the command line, Ubuntu provides a graphical user interface (GUI) to manage users easily.

  1. Open the settings and select the “Users” tab.
  2. Click “Unlock” and enter the administrator password.
  3. Click “Add User” and fill in the required information.

The GUI provides an intuitive way to manage users, making it a great option for those unfamiliar with the command line.

7. Granting Administrative Privileges to a New User

Users with administrative privileges can execute commands affecting the entire system using sudo. To grant administrative privileges to a new user, use the following command:

sudo usermod -aG sudo username

This command adds the user to the sudo group, allowing them to perform administrative tasks. Important: Only grant administrative privileges to trusted users.

8. Removing a User with deluser

If a user is no longer needed, they can be removed using the deluser command.

The basic command to remove a user is:

sudo deluser username

To remove the user along with their home directory, use:

sudo deluser --remove-home username

Before deleting a user, ensure that any important data is backed up, as deleted files may not be recoverable.

9. Common Issues and Troubleshooting

Handling Error Messages:

  • If you receive a “Permission denied” error, it means the user lacks sudo privileges. Request access from the administrator or add yourself to the sudo group.
  • If the adduser command returns “User already exists,” choose a different username.

You can verify whether a user has been successfully added by running the following command:

grep username /etc/passwd

10. Conclusion

User management in Ubuntu is essential for maintaining system security and efficiency. The adduser command allows easy user creation, customization, and granting of administrative privileges. Additionally, Ubuntu provides a GUI option for managing users, making it accessible even for beginners.

By following this guide, you can master the basics of user management in Ubuntu and ensure a more efficient and secure system operation.

年収訴求