Search This Blog

Sunday, October 21, 2018

adduser vs. useradd

adduser is a "high-level" script developed around "low-level" useradd. So, adduser is userfriendlier. For example, it creates and sets up the user's home folder by default, whereas in adduser you have to remember to specify the paramter (-m). useradd, like any self-respecting linux command shall only do what you ask. 

Some recommend always using adduser. If you wish to a adopt this strategy, it can be remembered as the "better" alternative by recalling that it is the "most intuitive" of the two, because its name is "proper english" (you use the command to add a user. not to useradd...) 

Two points to remember
1) there have been reports of differences in implementation of adduser in different linux flavors (with people reporting on it missing altogether from some, although I doubt that it is really missing, and more reasonably wasn't automatically installed on some core-installtion). 
2) people complain that adduser does a lot of things in the background that might be disruptive for users that are for system services, which might be a case for useradd... 

A practical demonstration
adduser gil 

is the equivalent of

useradd gil -m 
passwd gil

a last remark
why is home directory important to remember when setting up a user? 
while in terminal mode you can login with a user that has no home folder (and you will receive a notification "no directory. loggin in with HOME=/") .
X can't login a user that has no home folder (think of all the structures it maintains under your $HOME folder, and how in first logins in weak machines it takes more time because of the automatic creation of those).
Sadly, all distributions I know tend to handle a home-less user in a very foolish way, by throwing you back to the login screen, without explanation....