Powered By Blogger

Sunday, May 1, 2011

Managing CentOS Users and Groups



c r e a t i n g    u s e r s
syntax:
useradd [options] {username}
e.g.:
useradd --home /home/john john
useradd dhee

a d d i n g    p a s s w o r d
syntax:
passwd {password}
e.g.:
passwd dhee
*** Without pw, user account will be in lock status.

s e t    a c c o u n t    d i s a b l e    d a t e
syntax:
useradd -e {yyyy-mm-dd} {username}
e.g:
useradd -e 2011-06-28 dhee

s e t    d e f a u l t    p a s s w o r d    e x p i r y
syntax:
useradd -f {days} {username}
3.g.:
useradd -f -1 john
*** Type man useradd for options

l i s t i n g    a l l    u s e r s
e.g.:
cat /etc/passwd | grep "/home"
cat /etc/passwd | grep "/home" |cut -d: -f1
cat /etc/passwd | grep "/bin/bash" |cut -d: -f1

d e l e t i n g    a n    a c c o u n t
syntax:
userdel {username}
e.g.:
userrdel john

d e l e t i n g    u s e r ' s    h o m e    d i r e c t o r y
syntax:
userdel --remove {username}
e.g:
userdel --remove john

r e m o v i n g    a n    e m p t y    d i r e c t o r y
syntax:
rm -rf userdirectory
e.g.:
rm -rf john

a d d i n g    a    g r o u p
syntax:
groupadd {group}
e.g.:
groupadd accounts

a d d    a    u s e r    i n    a    g r o u p
syntax:
usermod -G {group} {account}
e.g.:
usermod -G accounts,sales,support john
usermod -a -G accounts,sales,support john

v i e w i n g    a l l    m e m b e r s    o f    a    g r o u p
syntax:
egrep "groupname" /etc/group
e.g.:
egrep "personal" /etc/group

d e l e t i n g    a    g r o u p
syntax:
groupdel {group}
e.g.:
groupdel accounts
***A group cannot be deleted if it is the primary group for any user.

No comments:

Post a Comment