How to Create and Manage User Accounts in Ubuntu Linux

If you are managing a Linux server or sharing a desktop machine with colleagues, it is a massive security risk to allow everyone to log in using the same credentials. Relying on a single account—especially the powerful root account—makes it impossible to track changes and severely compromises system integrity.

Knowing how to create and manage user accounts in Ubuntu Linux is a foundational system administration skill. By providing each person with their own isolated account, you can restrict permissions, protect personal files, and maintain a secure operating system environment.

How to Create a New User in Ubuntu

The easiest and most reliable way to create a new user account in Ubuntu is by using the terminal. Ubuntu provides a user-friendly interactive command called adduser.

  1. Open your terminal.
  2. To create a new user, type the following command, replacing username with the actual name you want to assign:
    sudo adduser username
  3. You will be prompted to enter your own sudo password to authorise the action.
  4. The system will automatically create the new user, generate a home directory (/home/username), and ask you to create a new password for the account. Type a strong password and press Enter (the text will remain invisible as you type).
  5. Confirm the password by typing it again.
  6. You will then be asked for additional information, such as the user’s Full Name, Room Number, and Work Phone. You can press Enter to skip these fields if they are unnecessary.
  7. Finally, type Y and press Enter to confirm the information is correct.

How to Grant Sudo Privileges to a User

By default, newly created users possess standard privileges. They can modify files within their own home directory but cannot install software or alter system configuration files. If the new user requires administrative capabilities, you must add them to the sudo group.

  1. In the terminal, run the following command:
    sudo usermod -aG sudo username

The -aG flag stands for “append to Group”. This ensures the user is added to the sudo group without being accidentally removed from any other groups they currently belong to. The user will now be able to execute administrative commands by prefixing them with sudo.

How to Change a User’s Password

If a user forgets their password, or if security policies require a mandatory password rotation, you can easily reset it as an administrator.

  1. Run the passwd command followed by the username:
    sudo passwd username
  2. You will be prompted to enter the new password twice to confirm it.

How to Delete a User Account

When an employee leaves or a temporary account is no longer required, it is crucial to remove the user to maintain system security.

  1. To delete a user account while keeping their files intact (in case you need to access their data later), run:
    sudo deluser username
  2. If you want to completely remove the user and permanently delete their home directory and all associated files, use the --remove-home flag:
    sudo deluser --remove-home username

By mastering these basic commands, you can efficiently control access to your Ubuntu system, ensuring that only authorised individuals have the privileges they need to perform their tasks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.