groupadd
Linux Commands - Manage Users and Groups

groupadd

Groups Every user will be created and added to a group. Groups are a effective method of managing users with similar needs. The command to create a group is groupadd. There are a number of options that can be used with the groupadd command. If you wanted to add a new group called sales you would use the following command:

groupadd
groupadd sales

-g gid group number, 0-499 are usually for system accounts

-r the group added will be a system account

-f this option will not allow you to exit if a group with the same name exists

-o this will allow you to use an existing gid if used with the

-g option -help group Files When a group is created, or another user is added to a group, several files will be changed.

/etc/group - contains group information /etc/gshadow - contains the secure account information

 

groupadd
When you would like to add a group this is the command to use. Here is an example:

groupadd tech

gpasswd
Use this command to add a password to a specific group. This may be handy when you have a group that will share a directory.

groupmod
Options
-n name modify the name of a group
In the example a group is added called tech but then modified to technology.
groupadd tech

groupmod -n technology tech

groupdel
Deleting a group can be performed with this command.

groupdel tech

passwd
This command provides an interactive interface to create passwords for users.

Options for root Only
-l lock account
A user may change their own account password by typing the command. The user must supply their current password to make the change.

passwd
Changing password for joe
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Some password management is done to encourage good passwords, see the example.
passwd
Changing password for joe
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
Bad: new and old password are too similar

 

As root the superuser may change any user by using the passwd command and then entering the username. The example shows the changing of the password for joe.

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

chage
The chage command modifies the aging properties of a password. This command allows you to set the time a password expires for example.

Options
-E expirationdate set date for expiration MM/DD/YY or MM/DD/YYYY
-l list user password settings
The example lists the settings for joe.

chage -l joe

Minimum: 0
Maximum: 99999
Warning: 7
Inactive: -1
Last Change: Sep 05, 2005
Password Expires: Never
Password Inactive: Never
Account Expires: Never

The next example shows changing joe's password expiration date and then the out put of listing his settings after it was changed. Note that it shows the date it was changed on.
chage -E 08/12/06 joe
root@ub:/home/mike # chage -l joe
Minimum: 0
Maximum: 99999
Warning: 7
Inactive: -1
Last Change: Sep 05, 2005
Password Expires: Never
Password Inactive: Never
Account Expires: Aug 12, 2006