How to Add Users in Linux
Introduction
Adding users in a Linux operating system is a straightforward process that can be accomplished through the command line. This how-to guide will walk you through the steps to add a new user to your Linux system and configure user privileges.
This guide explains the steps to add users to a Linux system. It emphasizes opening the terminal, acquiring root privileges, adding a new user using the ‘adduser’ command, configuring user details with ‘usermod’ (optional), granting administrative privileges through the ‘sudo’ group (optional), verifying the user addition by listing the user directory, and finally, exiting root privileges. By following these steps, users can successfully add new users to their Linux system and assign appropriate privileges.
Note: To add users, you need to have administrative or root access on your Linux distribution.
Step 1: Open the Terminal
Launch the Terminal application on your Linux system. The Terminal can usually be found in the Applications or Utilities folder, or you can initiate it by pressing Ctrl+Alt+T.
Step 2: Access Root Privileges
To add users, you will need root privileges. Use the following command and enter your root password when prompted:
sudo su
Alternatively, you can use su
followed by the root password to acquire root privileges.
Step 3: Add a User
To add a new user, use the adduser
command followed by the desired username. For example, to add a user named “john”:
adduser john
You will be prompted to enter and confirm a new password for the user. Provide the necessary details as requested.
Step 4: Configure User Details (Optional)
You can provide additional information about the user by running the usermod
command. For example, if you want to set the user’s full name, use the following command:
usermod -c "John Smith" john
You can modify other user details like the home directory or login shell by using appropriate usermod
options.
Step 5: Grant Administrative Privileges (Optional)
If you want to grant administrative privileges to the user, you can add them to the sudo group. Execute the following command:
usermod -aG sudo john
This command adds the user “john” to the “sudo” group, allowing them to execute commands with superuser privileges.
Step 6: Verify User Addition
You can confirm that the user has been successfully added by listing the user directory. Use the following command:
ls /home
This will display all the user directories, including the newly added user’s directory.
Step 7: Exit Root Privileges
Once you have finished adding the user and configuring privileges, you can exit the root user by typing:
exit
This will return you to your regular user account on Linux.
Conclusion
Congratulations! You have successfully added a new user to your Linux system. You can now let others access the system with their own credentials while ensuring the appropriate privileges are assigned to each user.