+ -

Pages

Sunday, June 2, 2013

Linux: User and Group Management – Key Commands and Utilities


Managing Users


Adding Users

useradd - this cmd is used to add new user to the system

-d           specify home dir

-e           expiry date

-s            shell

-G           group

-u           UID


/etc/login.defs  - this file stores all the parameters for users

passwd [username]  - creates a password for the user

usermod
This modifies user's account
-m          used with -d, this moves contents of the current home dir to the new one specified
-U           unlocks password
-L            locks account
-l             changes username (usermod -l new_username old_username)

chage
This command deals with account expiration
-m          sets the minimum time before a user can change password. Usage: -m 1 (1 day)
-M          sets the maximum time after which password needs to be changed
-d           sets the last day the password was changed (can be used to manipulate account info)
-I            sets number of inactive days allowed before password expires
-E           sets expiration date
-W          sets warndays – warn the user before the password expires

Deleting Accounts


userdel                              
This cmd is used to delete users from a system.
Options:
-r            remove all the files from home dir and mail spool
-f            force deletion of the account (when the user is logged in)
-h           get help

Managing groups

/etc/group - this file controls the group membership (also /etc/gshadow)

/etc/passwd - this file contains info on the user's primary group (also /etc/shadow)

newgrp - this cmd is used for changing current group to a different one

chgrp - this cmd is used to change the group of a file or dir

First 100 GIDs and UIDs (0-99) are reserved for system use (generally)

0 UID/GID belongs to root - always

 

Adding groups


groupadd
This cmd adds a new group to the system.
Options:
-g           specifies a GID
-r            creates a system group
-f            forces creation

 

Modifying groups


groupmod
This cmd modifies a group.
Options:
-g           specify a new group ID for an existing group
-n           specify a new group name for an existing group
gpasswd
This cmd sets a password for the group
Options:
-a           add a user to the group                  usage:   -a user group
-d           delete a user from the group        usage:   -d user group
-R           configures a group to not allow the cmd newgrp
-r            removes the password from a group
-A           specify group admin

 

Deleting groups


groupdel
This cmd deletes a group





5 RakshaTec: Linux: User and Group Management – Key Commands and Utilities Users and Groups Managing Users Adding Users useradd - this cmd is used to add new user to the system -d        ...

No comments:

Post a Comment

< >