USER ADMINISTRATION IN LINUX

Different kinds of users in Linux

We can divide users into two different catagories-

1.Normal Users or Standard Users: – having limited access on the system
2.Root/Superuser/Administrator: - this user is having full access to the entire Linux system

UID- User Identifier - / GID-Group Identifier

UID – 0 - for root user
UIDs1 – 999 – Reserve for system accounts
UIDs 1000+ - for Normal user accounts

#id
$id


Add Normal users


#useradd user1
#passwd user1
Password:123
Confirm:123
#useradd user2
#passwd user2
Password:123
Confirm:123
      

As you add the user its entry is created in /etc/passwd , /etc/group and /etc/shadow files
/etc/passwd - All user accounts entries
/etc/group – Normal and supplementary groups
/etc/shadow – Encrypted passwords


Adding user in Linux system creates –


1. Assign User ID - UID
2. Entry in /etc/passwd
3. Entry in /etc/group
4. Entry in /etc/shadow
5. Creates home directory in /home/<username>
6. Set up default shell /bin/bash
7. All files of /etc/skel are copied to the home directory of new user.
8. .bashrc, .bash_profile & .bash_logout are copied to the home
directory of new user.
9. These files set environment variables for the users session in
Linux.
Modify the user settings
#usermod
Usermod switches:-
-a Add -c Comments -d Specify different home directory for user -g GROUP Specify primary group for the user -G GROUP Specify Secondary /Supplementary group -L Lock the user -U Unlock the user -l Change login name -s SHELL Change default shell

Changing comment of an existing user:-


                                    
#usermod –c “AIT Student” user1
      

Add user to Secondary group:-


#groupadd accounts
#usermod –G accounts user1
      

Changing users home directory:-


#mkdir /home/ait1
#usermod -d /home/ait1 user2
      

Change users Primary Login group:-


#groupadd aws
#usermod -g aws user2
      

Change login name:-


#usermod -l azhar abdul
      

Lock user account:-


#usermod -L user2
      

Unlock user account:-


#usermod -U user2
      

Change login shell:-


#useradd ishan
#usermod -s /bin/sh Ishan
      

Delete user Ayen without deleting his home directory:-


#useradd Ayen
#userdel Ayen
      

Change UID of user:-


#useradd –u 2000 user3