Vous êtes sur la page 1sur 5

(1) Users & Groups Management

Step GUI tool s Command line tools


Tool name Executable name Package name useradd userdel usermod
User Manager system-config-users system-config-users groupadd groupdel groupmod
(System Administration passwd chage
Users and Groups)
1. Add new User # useradd <username>
(Create a new user and its primary
group with the same name)
options:
-s /sbin/csh (specify the login shell)
-d /home/dir1 (specify the home directory)
-u <UID> (specify the user id)
-g <GID> (specify an existing group to be the
primary group)

:
) id( ) user( ) UID( o
) user( ) id(

)root user( ) UID = 0( o
)system user( ) UID = 1499(
)normal user( ) UID >=500(
: :) user( o
) login( ) nologin shell( )new user( for username in ali mohamed ahmed;
)Login Shell : /sbin/nologin( do
useradd $username;
echo password | passwd --stdin $username ;
) Create a private group for the user( done
) primary group( )keyboard( ) pipe( ) --stdin( :
)hidden by default( ) users( ) primary group(
)Edit Preferences( # passwd <username> (set the user password)
# id (show information for current user)
#id <username> (show information for the specified user)
) group( ) user(
Step GUI tool s Command line tools
2. Add new Group # groupadd <groupname> (Create a new group)
# groupadd -g <GID> <groupname>
(Create a new group with
the specified group id)

3. Add a user to a # usermod -aG <groupname> <username>


supplementary (add the specified group as a
group supplementary group for the specified user)

:
) append( ) -a(
) user( ) supplementary groups(

# usermod -g <groupname> <username>
(change the primary group for the specified
user)

4. Delete a user # userdel <username>


:
) user( (delete a user without
deleting the home directory)
# userdel -r <username>
(delete a user and delete the
home directory)
:
user ( ) account( ) -r(
) user( ) home directory
) old home directory( ) UID(
) user(

) user( ) user( ) primary group(


) primary group( ) user(
Step GUI tool s Command line tools
5. Delete a group #groupdel <groupnanme> (delete a group)
:
) user( ) user( ) primary group(

6. Enable account # chage -E 2012-03-26 <username>


expiration # chage -E -1 <username> (cancel the expiration)

:
30 ) expiration date(

# date -d +30 days

7. Lock the user # usermod -L <username> (Lock the account)


account # usermod -U <username> (Unlock the account)
Step GUI tool s Command line tools
8. Password aging
policy

max days

min days warn days inactive

days

last change password inactive


date expiration
date
date

: # chage -m 2 -M 90 -W7 -I10 <username>


Days before change allowed #chage -l <username> (display current password age policy
for the user)
note:
Days before account inactive
-m (min days)
) password( ) account( -M (max days)
-W (warn days)
-I (inactive days)
note:
# chage -d 0 <user>
)next login( ) password( ) user(
(2) General Notices
)/etc/passwd( ) users(

username : password : UserID : GroupID : GECOS : /home/dir : shell


note:
o password (not the real password, this field is not used )
o GECOS (store arbitrary text (e.g. the full user name))

)/etc/shadow( ) passwords(

username : password hash : last password change : min password age : max password age : password warning period : password inactive period : account expiration
note:
o last password change (number of days since 1/1/1970) = date of the last time the password changed
o min password age (in days , 0 = no min age requirement)
o max password age (in days)
o password warning period (in days , 0 = no warning given)
o password inactive period (in days)
o account expiration (number of days since 1/1/1970)
)/etc/group( ) groups(
groupname : password : GroupID : list of users

) supplementary group( ) supplementary group( ) user( ) user( ) primary group(

Vous aimerez peut-être aussi