Difference between useradd and adduser commands

Solved
Guiwald -  
 Linux -
Hello,
I would like to know the difference between the "adduser" and "useradd" commands in Linux.
Thank you for your answers.

13 réponses

Bifidus (is back, mais pas trop) Posted messages 18 Status Membre 69
 
adduser is an interactive command: it asks you questions, and you must answer them.
useradd is a non-interactive command, you can use it in a script.
Basically, you will only use adduser, which does much more for you than useradd (which it calls anyway).

HTH
70
Guru0 Posted messages 51 Status Membre 2
 
Hello,
The syntax is roughly as follows (it depends on the
version of Unix/Linux):

usage: useradd [-u uid [-o] [-i]] | -g group | -G group[[,group]...] | -d dir |

-s shell | -c comment | -m [-k skel_dir] | -f inactive | -e expire ] login
useradd -D [-g group | -b base_dir | -f inactive | -e expire ]

USAGE: /sbin/adduser <login id> <name> <user id> <home directory>

The easiest way is to run a man on both commands
and test them to create users

Best regards,
4
asevere Posted messages 13095 Registration date   Status Webmaster Last intervention   426
 
 [shell]# adduser usage: adduser [-u uid [-o]] [-g group] [-G group,...] [-d home] [-s shell] [-c comment] [-m [-k template]] [-f inactive] [-e expire ] [-p passwd] [-M] [-n] [-r] name adduser -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ] [shell]# useradd usage: useradd [-u uid [-o]] [-g group] [-G group,...] [-d home] [-s shell] [-c comment] [-m [-k template]] [-f inactive] [-e expire ] [-p passwd] [-M] [-n] [-r] name useradd -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ] [shell]# ll /usr/sbin/adduser lrwxr-xr-x 1 root root 7 mai 7 21:57 /usr/sbin/adduser -> useradd* 


In my case... (Maybe not for everyone) it's the same thing :)
"If it's stupid and it works, then it isn't stupid"
4
Bifidus (is back, mais pas trop) Posted messages 18 Status Membre 69
 
It’s quite surprising.
What system are you using?
-1
Guiwald
 
I'm sorry, but your answer doesn't help me better understand the difference between these two commands :)
You indicate that the syntax is different (OK, adduser is not useradd), as well as the options (what are the different options between the two commands?), but that the result is the same (how is that possible, with different options?).

Basically, when should I use adduser, and when should I use useradd?
1
asevere Posted messages 13095 Registration date   Status Webmaster Last intervention   426
 
Re,

It seems logical to me... it must be the only standard command, other Unix systems must have brought in adduser, so for compatibility there might eventually be a link...
A priori, for the Linux RH LPI certifications, only the "useradd" command needs to be known
So that one must be on all distributions, the other is a plus :)

@++

"If it's stupid and it works, then it's not stupid"
1
jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   4 898
 
Hello.
Same as "asevere"
[root@Mandrake root]# adduser usage: adduser [-u uid [-o]] [-g group] [-G group,...] [-d home] [-s shell] [-c comment] [-m [-k template]] [-f inactive] [-e expire ] [-p passwd] [-M] [-n] [-r] name adduser -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ] [root@Mandrake root]# useradd usage: useradd [-u uid [-o]] [-g group] [-G group,...] [-d home] [-s shell] [-c comment] [-m [-k template]] [-f inactive] [-e expire ] [-p passwd] [-M] [-n] [-r] name useradd -D [-g group] [-b base] [-s shell] [-f inactive] [-e expire ]
For your information: Mandrake 9.0
@+
JP___ and don't forget little scarab... "google" is your friend! ;-)
0
asevere Posted messages 13095 Registration date   Status Webmaster Last intervention   426
 
Hello everyone!

Thanks JP for not leaving me all alone :)
This is the result on my Mandrake 9.0
I haven't tested it with others yet
@++

"If it’s stupid and it works, then it’s not stupid"
-1
mouna
 
useradd and adduser are used to add a user in Linux, so they have the same function.
0
jipicy Posted messages 40842 Registration date   Status Modérateur Last intervention   4 898
 
Hi asevere.
Under "Suse 8.1," the "useradd" gives the same result, but the "adduser" is unknown to the "bash."
@+

JP___ and don't forget little scarab... "google" is your friend! ;-)
0
Maximax_Minimax
 
If you want to know everything, go here:
http://doc.ubuntu-fr.org/adduser#creer_un_compte_ou_un_groupe_d_utilisateurs_de_maniere_non-interactive
0
roota
 
I am a beginner with Linux, and when I create a new user with the adduser command, I can log in with this new account. However, when I create a new user with the useradd command, I cannot log in, and I can't even shut down my PC; I have to force it off by pressing the power button.
0
Liloulinx
 
Under RedHat 5, adduser is just a link to "useradd".


[root@vm2 gpf]# ll /usr/sbin/ |grep user
lrwxrwxrwx 1 root Apr 8 2008 adduser -> useradd
0
Linux
 
adduser is for creating an account and useradd is to create a session in a specific environment!
0
Guru0 Posted messages 51 Status Membre 2
 
Hello;
The syntax is different... and the options
but the result is the same.
-2