In most Linux systems, when you want to create a new user, you have two options: adduser or useradd.
So, what exactly is the difference between the two? Is one of them superior to the other? Which should you choose? Is it useradd or adduser?
More in this thread🐧↓
So, what exactly is the difference between the two? Is one of them superior to the other? Which should you choose? Is it useradd or adduser?
More in this thread🐧↓
Useradd is a built-in Linux command that is available on all Linux systems. However, creating new users with this low-level (limited) command is a time-consuming task because it does not automatically create the home directory and user password.
On the other hand, adduser is not a standard command in Linux. It's purely a Perl script that runs in the background and employs the useradd command.
This high-level utility is more effective at creating new Linux users, as it allows you to create a home directory, set a password, and configure a few other settings upon user creation.
Now that you understand the differences between the useradd and adduser commands, let's look at how to use these commands to create users in Linux.
Adduser command
Some Linux distributions do not include the Adduser command. Others have a soft link to useradd. For some, it is a Perl script.
Some Linux distributions do not include the Adduser command. Others have a soft link to useradd. For some, it is a Perl script.
Adduser is an interactive high-level utility. This command is less interactive than the adduser command. As a backend, it employs the low-level utility useradd.
When using the adduser command, the settings in /etc/login.defs will be used. Even the man page on Debian-based distributions recommends it over the useradd command.
The above command will add a new user to your Linux system. It will ask for some details and after entering those details a new user account would be created.
To achieve nearly the same result as adduser by using the low-level utility useradd, the command would look like this:
$ sudo useradd -d /home/coffeaddicts -m -s/bin/zsh -p secretpass -c FullName,Phone,Other Information
$ sudo useradd -d /home/coffeaddicts -m -s/bin/zsh -p secretpass -c FullName,Phone,Other Information
It is also important to know that you can omit the -c option if you don't wish to add user infomation.
The Adduser command provides you with a number of options. Here is a short list of the most important ones. For more information, see the help or man pages.
The Adduser command provides you with a number of options. Here is a short list of the most important ones. For more information, see the help or man pages.
• system - Create a new system user. System users are automatically assigned to the nogroup group. Use the -gid or -ingroup options to add a system user to an existing group.
• home DIR - Instead of the default home directory, use DIR. If necessary, a directory will be created and skeleton files copied.
• shell SHELL - Instead of the default, use SHELL.
• ingroup GROUP: Change the primary group of the user to GROUP.
• add_extra_groups: Add a new user to a configuration-defined extra group.
• ingroup GROUP: Change the primary group of the user to GROUP.
• add_extra_groups: Add a new user to a configuration-defined extra group.
The configuration file for Adduser allows you to specify the default values that will be used when creating the account. The file is well documented and allows you to configure default values such as:
• Default shell
• Home directory
• Extra groups
• Add extra groups
• Home directory
• Extra groups
• Add extra groups
In my experience as a Linux power user, adduser is far superior at creating new users in Linux. I use it more frequently when I need to create users. As a result, I recommend that everyone use it.
So how about you? Which do you prefer, adduser or useradd?
So how about you? Which do you prefer, adduser or useradd?
That's all! Thank you for getting this far. I hope you find this thread useful.
If you found this thread valuable:
1. Toss us a follow for more daily threads on Linux, sysadmin, and DevOps →
@linuxopsys
2. Like and RT the first tweet so other Linux folks can find it too.
If you found this thread valuable:
1. Toss us a follow for more daily threads on Linux, sysadmin, and DevOps →
@linuxopsys
2. Like and RT the first tweet so other Linux folks can find it too.
Loading suggestions...