Linux Scroll

Just another site

Linux manage user

Create user:

$ useradd -m -c "full name" %username
$ passwd %username


-m = auto create new user home directory (home template /etc/skel/)
-c = comment mostly new user full name
-u = set UID
-g = set primary group of new user
-p = set encrypted passwd (use mkpasswd to create)
-e = set expiration date YYYY-MM-DD

Useradd template:

$ sudo vi /etc/default/useradd

Modify user account:

$ usermod -u 1001 %username (change UID)
$ usermod -d /data/%username -m %username (move home directory)

Delete user account:

$ userdel -r %username (del user account and home directory)

Remember to locate user id before delete user account.
Delete all the file belong to user:

$ find / -uid XXXX -exec rm {}\;

Lock user account:

$ passwd -l %username

Unlock user account:

$ passwd -u %username

Check user account status:

$ passwd -S %username
username PS MM/DD/YYYY 0 99999 7 -1

PS = valid passwd
LK = account locked
NP = no passwd
MM/DD/YYYY = date last passwd change
0 = min length of validity
99999 = max length of validity
7 = warning period
-1 = inactivity when a password expired


-i xx = disable an account after password expired for xx days
-n xx = min xx of date before password can change
-w xx = warning in xx of days password will expire
-x xx = max xx of days password remain valid

Check UID;

$ id %username
$ finger %username

Linux user database: /etc/passwd
username:x:1000:100:Full Name:/home/username:/bin/bash
username:password:UID:GID:comment:home directory:login shell

passwd conf:

0 = root
0 – 99 = system
100 – 499 = system users
Normal user start from 1000

Linux user password database: /etc/shadow
username:encrypted password:last change:next possible change:next obligatory change:warning:limit:lock


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: