Create and Manage Users

Ubuntu: Create and Manage Users

Managing users is a critical part of server administration. Creating separate accounts improves security, allows role-based access, and makes it easier to manage multiple users. This guide explains how to create and manage users on Ubuntu servers.


Step 1: Create a New User

sudo adduser username

This command creates a new user and prompts you to set a password and optional details.


Step 2: Assign Sudo Privileges

sudo usermod -aG sudo username

This adds the user to the sudo group, allowing them to run administrative commands.


Step 3: Switch to the New User

su - username

This switches the current session to the new user.


Step 4: Delete a User (Optional)

sudo deluser username

To remove a user and their home directory:

sudo deluser --remove-home username


Step 5: List All Users

cut -d: -f1 /etc/passwd

This displays all user accounts on the system.


Step 6: Manage Groups

Create a new group:

sudo addgroup developers

Add a user to a group:

sudo usermod -aG developers username


Best Practices

  • Always disable root login for security
  • Use unique usernames for each client or developer
  • Assign sudo privileges only when necessary
  • Regularly audit users and groups

Note: HostPalace servers come pre-configured with secure defaults, but creating and managing users is recommended for multi-user environments.