Adding a User Linux

Add a user (user) on GNU/Linux can be done with the user's command "useradd" or "adduser". The command "useradd" command is compiled along with the original GNU/Linux system, whereas the adduser is a perl script that uses the useradd as back-end. Basic commands useradd is
# useradd -[opsi] username

Adding a new user
To add a new user, run the command
# useradd new username

After that add a new username for password by running the command:
# passwd new username

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

After a new user is created, the data will automatically be added to the "/etc/passwd"
new username:x:1001:1002::/home/new username:

That line contains the information separated by a colon (:), the information is from left to right are:
  1. Username: login name for the user
  2. Password: the password of the user, is replaced by the character ' x '. The user password is stored encrypted in the "/etc/shadow".
  3. User ID
  4. Group ID
  5. User info: contains optional information
  6. User directory
  7. Shell

Add a new user with a different user directory
At default settings, the user directory for the user is at "/home/username". To create a new user with a different user directory can be done by adding the parameter "-d"
# useradd -d /other/path new username

The "useradd" command will not create user directory automatically. To create a user directory automatically when you create a new user, please add the parameter --create-home or -m.
# useradd -m new username
# useradd --create-home new username

Adding new users at several group
To put on some new users group can use the parameter "-G", or "groups"
# useradd -G vboxusers,operator new username

The above command will create a new user with the username, new username and place it on the 3 group. To examine the results of these commands can use the command:
# groups new username
new username : new username operator vboxusers
To add an existing user into group
# usermod -a -G wheel old username

Delete user from Group
To remove a user from a group, do so by using the command "deluser <username> <groupname>". An example of the command to remove the "new username" from the group operators:
# deluser new username operator
# gpasswd -d new username operator
Delete a user
To remove a user, use the command
# userdel -r <username>

So this entry for more details, can see the manpages
$ man useradd

Click here for Comments