Linux: Managing Users


Useradd :

  • The useradd utility will first check the /etc/login.defs file for default values for creating a new account
  • For those defaults not defined in /etc/login.defs file, useradd supplies its own.
  • You can display these defaults using the useradd command with the -D option.
  • The default values include the group name, the user ID, the home directory, the skel directory, and the login shell.
  • Values the user enters on the command line will override corresponding defaults. The group name is the name of the group in which the new account is placed.
  • By default, this is other, which means the new account belongs to no group. The user ID is a number identifying the user account. This starts at 500 on Red Hat with the first account and increments automatically for each new account.
  • The skel directory is the system directory that holds copies of initialization files. These initialization files are copied into the user's new home directory when it is created. The login shell is the pathname for the particular shell the user plans to use.
  • The useradd command has options that correspond to each default value
  • You can use specific values in place of any of these defaults when creating a particular account. The login is inaccessible until you do. In the next example, the group name for the vish account is set to test1 and the user ID is set to 573:

Example: useradd vish -g test1 -u 573

usermod :

The usermod command enables you to change the values for any of these features. You can change the home directory or the user ID. You can even change the user name for the account.

userdel :

userdel command enables you to delete the user's login. In the next example, the user vish is removed from the system:

Example: userdel -r vish

Note: You can also add a new user to the system with the adduser utility. The Red Hat version of adduser takes as its argument the user name for the account you are creating. adduser has options similar to useradd.

Help on different commands:

  • Use man < command > to display help for that command
  • Output is presented a page at a time. Use character b to scroll backward, character f or a space to scroll forward and character q to quit

Example: man useradd


Next>> Linux: Managing Groups


Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus










Footer1