Creating a New User on Ubuntu Server 24
Creating and managing users on Ubuntu Server is a fundamental skill for system administrators. This comprehensive guide will walk you through the entire process of adding a new user, assigning appropriate privileges, and verifying the setup on Ubuntu Server 24.
1. Access the Terminal
To start, you need to access the terminal on your Ubuntu Server. If you're working directly on the server, you should already be at the terminal. If you're connecting remotely, use SSH to log in.
ssh your-username@your-server-ip
2. Create a New User
The adduser
command is used to create a new user. Replace newuser
with your desired username. The adduser
command is user-friendly and prompts you to enter additional information.
sudo adduser newuser
Steps:
- Enter and confirm a password for the new user.
- Provide additional user information such as Full Name, Room Number, Work Phone, Home Phone, and Other. You can press Enter to skip fields you don't want to fill in.
3. Grant Administrative Privileges (Optional)
If the new user needs administrative privileges, you'll need to add them to the sudo
group. This step is optional and should be used only if the user requires elevated permissions.
sudo usermod -aG sudo newuser
Explanation:
usermod
is the command to modify a user account.aG
adds the user to the specified group.sudo
is the group that grants administrative permissions.
4. Verify the New User
To ensure that the new user has been created successfully, you can list the home directories:
ls /home
You should see the new user's directory listed.
To switch to the new user account and verify that it works, use the following command:
su - newuser
This command switches the current user to newuser
. You will need to enter the password you set during the user creation process.
5. Additional User Management Commands
Here are some additional commands that might be useful for managing users:
- Delete a User:
To delete the user's home directory as well:sudo deluser newuser
sudo deluser --remove-home newuser
- Change a User's Password:
sudo passwd newuser
- View User Information:
id newuser
6. Conclusion
You've now successfully created and configured a new user on your Ubuntu Server 24. This user can be customized further according to your needs, and you can manage user permissions to fit various administrative roles.