useradd

linux

How can we add a user to the system with the home directory to be /code/htdocs, and default group is marketing?

useradd -d /code/htdocs -g marketing username

How can we create a user username that belong to group groupname and do not allow user to log into the system?

useradd username -g groupname -s /sbin/nologin

What are the options for the useradd command?

-u uid    // specifies the UID, default to the next highest
-g group    // specifies the primary group
-G groups    // specifies a comma separated list of secondary groups
-b basedir    // specifies the default home directory (for example /home)
-d dir        // specifies the home directory (default: -b/username)
-m        // creates the home directory in addition to defining the user
-s shell    // specifies the default login shell.  Default to empty field which default to /bin/sh
-c name    // specifies the full name
-k dir        // specifies the skeleton directory containing initialization file (/etc/skeleton)
-f n        // specifies the number of days the account can be inactive before being disabled

What are the equivalent command to useradd on other platform?

admintool    (Solaris)
mkuser    (AIX)
passwd -l chavez (IRIX, SCO, Linux)
chuser login=no chavez (AIX)

What are the equivalent command to userdel on other platform?

rmuser -p chavez (AIX)
/tcb/bin/rmuser chavez (SCO, requires UIDREUSE be set to YES in /etc/default/login)
removeuser (Digital Unix)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License