Home Tips and Instructions Linux & UNIX Managing / Adding / Deleting Users on Linux / UNIX
Managing / Adding / Deleting Users on Linux / UNIX PDF Print E-mail

groupadd

groupadd is the command used to create a group. You would type groupadd new_group

Specific Example:

Typing groupadd family would create a new group titled family.  

useradd

useradd is the command used to create new users. To create a new user you would type:

useradd new_user

(This will add a new user and create a new group with the same name.) 

To create in new user in a particular group you would type:

useradd -g groupname new_user

usermod 

usermod is the command us to modify and existing user.

usermad has the following options:Example:

Options:

  • -d home directory
  • -s starting program (shell)
  • -p password
  • -g (primary group assigned to the users)
  • -G (Other groups the user belongs to)

Example: To add the group admin to the user trevor_gontz

usermod -G admin trevor_gontz 

passwd

passwd is the command used to create a password for a user account. To create a password for an account you would type:

passwd username and then you will be prompted with:

New password:

Retype new password:

and then you should see:

passwd: all authentication tokens updated successfully.

userdel

userdel is the command used to delete a user.

There is also an optianal -r switch that removes all of the contents of the user's home directory.

Example:

userdel -r john_doe would remove john_does home folder.  

groups

groups is the command used to determine which group a user belongs to. To determine which group that you (or the current user) belongs to you would type:

groups

To find out which group or groups another user belongs to you would type groups name_of_user.

Example:

To find out which group or groups john_doe belongs to you would type:

 groups john_doe


If you want to view a list of all groups then you would type:

less /etc/group

If it is a long list press the space bar to view another set and when you are finished press q to quit.



Adding a Long User Name to Ubuntu and Debian Linux

Up to Ubuntu 6.10 and Debian you cannot add long user names such as a firstname_lastname. In order to be able add long usernames then you have to use the adduser command with the --force-badname option.

For example, to force your system to create the username trevor_gontz you would type:

sudo adduser --force-badname trevor_gontz

Ubuntu will then return:

Allowing use of questionable username.

Once this occurs you can continue using adduser as you would normally.

*Note: If you wish to make users with a long username administrators then you must add them to the admin group via the command line with the usermod command. See my usermod section for instructions on how to do this. (You cannot use GNOME's Users and Groups tool to do this. It will insist upon you reverting back to a short username.)