Adding a new user to a Linux system is a straightforward process, especially when using the `adduser` command, which is more user-friendly compared to the `useradd` command. Below is a step-by-step guide to help you through the process.
Before starting, ensure you have:
Access to a Linux server with `root` privileges. This will allow you to perform administrative tasks such as installing software, modifying system configurations, and managing user accounts.
The following steps apply to both Debian and Ubuntu systems.
To add a new user, use the `adduser` command:
Linux (Debian/Ubuntu)
adduser your_username
Replace `your_username` with the desired username for the new user. This command will prompt you to enter and confirm the new user's password, as well as some additional information (e.g., full name, room number, work phone, home phone). You can skip these additional fields by pressing `Enter`.
If the previous step results in `adduser: command not found`, continue with these steps:
You can verify if `adduser` is installed on your Linux system using the `dpkg` Command:
The `dpkg` command is a powerful tool in Debian-based Linux systems that allows users to manage installed software packages. One of its useful features is the ability to query the package database directly. By using specific options with `dpkg`, such as `-l`, users can retrieve detailed information about installed packages.
Linux (Debian/Ubuntu)
dpkg -l | grep adduser
if `adduser` is installed on your system, the command will return a line that contains information about the `adduser` package. This line typically includes the package name, version number, architecture, and status (whether it's installed, configured, etc.).
If `adduser` is installed but not found in your system's path, find its location using:
Linux (Debian/Ubuntu)
which adduser
This command will print the full path to the `adduser` executable, if it exists.
Once you have located the full path of `adduser` (for example, `/usr/sbin/adduser`), you can execute it directly by typing the full path in the terminal:
Linux (Debian/Ubuntu)
/usr/sbin/adduser your_username
Replace `/usr/sbin/adduser` with the path you found using `which adduser`. This ensures you can use the command without relying on it being in the system's default path.
If the `which adduser` command doesn't return anything but you believe `adduser` is installed, you can use these alternative methods to locate it:
Linux (Debian/Ubuntu)
dpkg -L adduser | grep bin
This command lists all the files installed by the `adduser` package and then filters the output to show only those files located in directories with `bin` in their name, which usually contain executable files.
Linux (Debian/Ubuntu)
find / -name adduser 2>/dev/null
This command will search the entire filesystem for a file named `adduser`. The `2>/dev/null` part of the command suppresses any error messages about permission issues during the search.
If `adduser` command is not installed, you can install it using the `apt` package manager.
Linux (Debian/Ubuntu)
apt update
apt install adduser
After installing `adduser`, proceed with Step 1 to add your new user seamlessly. Always ensure you are operating as the root user (`su`) when executing commands that modify system configurations.
By following these steps, you can successfully add a new user to your Linux system using the `adduser` command. Whether using the command directly or after locating its full path, you ensure the new user is properly configured with a password and optional additional details.
Published: June 22, 2024
Have a question or suggestion? Want to request a tutorial or simply leave me a message? I'd love to hear from you! Join our community on Discord for exclusive content, engaging discussions, and more. Thank you! 🌟