Linux Useradd Usermod Userdel Command

Posted by admin | Linux Commands | Saturday 5 July 2008 6:40 pm

PAGE TAGS: linux user commands, linux user command, linux add user command, linux users command, linux command change user, linux command line user, linux command list users, linux add user command line, linux create user command line, linux delete user command, linux delete user command, linux command show users, linux user, linux users, linux add user, linux add users

LINUX USER COMMANDS AND FILES

useradd name = Create a user account. By default, when you create a user account, you create a home directory for that user with the same name under /home/username.

useradd -c text name = Add a description for the account in the GECOS field of /etc/passwd. Example: useradd -c “Paul Morrill” pmorril creates the pmorril account with a comment

useradd -d path name = Assign an absolute pathname to a custom home directory location. Example: useradd -d /tmpusr/sales1 sales1 creates the sales1 user account with home directory located at /tmpusr/sales1

useradd -u ID name = Assign the user a custom UID. This is useful if you want to assign ownership of files and directories to a different user. Example: useradd -u 789 dphilips creates the dphilips account with user ID 789

usermod name = Modify an existing user account. usermod uses the same switches as useradd.. Example: usermod -c “Paul Morril” pmorril changes the comment field for user pmorril

usermod -l newname name = Rename a user account. When renaming the account, use the -d switch to rename the home directory, and use the -m switch to copy all files from the existing home directory to the new home directory. Example: usermod -l esmith -d /home/esmith -m ejones renames the ejones account to esmith, renames the home directory, and moves the old home directory contents to the new location

usermod -s path name = Modifies the default shell setting for the user account.
Example: usermod -s /bin/tsch esmith points the shell for esmith to /bin/tsch

userdel name = Remove the user from the system. Example: userdel pmaxwell deletes the pmaxwell account while leaving the home directory on the system

userdel -r name = Remove the user and the user’s home directory. Example: userdel -r pmorril removes both the account and the home directory