X

Linux User management

USER ADMINISTRATION Files
——————-
/etc/passwd -> system users info
/etc/shadow
/etc/group
/etc/gshadow——–contains the shadowed information for group accounts.
/etc/login.defs —-same as /etc/default/security in HP UX
/etc/default/useradd– contains the default values for GROUP, HOME, INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel etc.
/etc/shells diff shells
/etc/skel/ ===== is a directory which contains all the files that are copied to a user’s home directory whenever a new user is created.
/var/log/wtmp
/var/log/lastlog=====stores user last login information.
/var/log/btmp

# useradd <user> -> create a new user
e.g.

[root@mann ~]# useradd testusr

 

# adduser <user> -^

# passwd <user> -> change password
eg.

[root@mann ~]# passwd testusr
Changing password for user testusr.
New password:
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

 

# passwd -l -> lock the user

e.g.

[root@mann ~]# passwd -l testusr
Locking password for user testusr.
passwd: Success

# passwd -S -> short information about the status of the password for a given account.Ths commands displays whether account lockout or not
same as getprpw in HPUX
eg

passwd -S testusr
testusr LK 2012-08-17 0 99999 7 -1 (Password locked.)

 

# passwd -uf -> will unlock the account password

[root@mann ~]# passwd -uf testusr
Unlocking password for user testusr.
passwd: Success

To recheck

[root@mann ~]# passwd -S testusr
testusr PS 2012-08-17 0 99999 7 -1 (Password set, MD5 crypt.)

 

$ passwd
# userdel <user> -> delete user
e.g.

[root@mann ~]# userdel testusr

 

# userdel -r -> delete user and his home directory

# usermod -> modify user
# usermod -G
# groupadd -> create a new group
# groupdel -> delete group
# groupmod -> modify group
# lastlog-u

e.g.

[root@mann ~]# lastlog -u testus1
Username Port From Latest
testus1 pts/3 192.168.0.40 Sat Aug 18 05:40:28 -0700 2012

 

# chfn -> change finger
e.g.

[root@mann ~]# chfn testus1
Changing finger information for testus1.
Name []: Manmohan Mirkar
Office []: Home Park
Office Phone []: xxx-xxxxxx
Home Phone []: 9819025476

 

Finger information changed.

[root@mann ~]# cat /etc/shadow|grep -i testus1
testus1:x:502:502:Manmohan Mirkar,Home Park,xxx-xxxxxxx,9819045476:/home/testus1:/bin/bash

 

# chsh -> change shell
# chage -d x change user password expiry information

e.g

[root@mann ~]# chage testus1
Changing the aging information for testus1
Enter the new value, or press ENTER for the default

Minimum Password Age [0]: 0
Maximum Password Age [99999]:
Last Password Change (YYYY-MM-DD) [2012-08-18]:
Password Expiration Warning [7]:
Password Inactive [-1]:
Account Expiration Date (YYYY-MM-DD) [1969-12-31]:

 

$ ulimit Limit user resources

To set a soft limit on the maximum amount of memory available to a given process to a value that is less than the total amount of memory on the system on a system with 1 gig of real memory and 500 megs of virtual memory you would set the following values in /etc/profile:

ulimit -S -m 1000000
ulimit -S -v 500000
With this value set, the system will kill any process that tries to take up more resources than you have set as a limit.

# pwck -> check passwd and shadow files in /etc
# grpck -> check group and gshadow files in /etc
# pwconv -> enable password shadowing
# pwunconv -> disable password shadowing
# grpconv -> enable group shadowing
# grpunconv -> disable group shadowing
# su <username>
# su -l <username>
# su – <username>
# su –