User’s and Group’s Administration

This post is about some information for users and groups in linux..
Whenever a USER is created in linux :-

  1. its home directory is created(/home/username)
  2. its mail box is created(/var/spool/mail)
  3. unique UID & GID are given to user

UID for system users 0 to 499

UID for normal users/regular users 500 to 60,000

Redhat Enterprise Linux and fedora used UPG scheme

UPG… User Private Group

it means that whenever a user is created is has its own private group

Create USER:

Syntax :  useradd <option> <username>

options are

-u user id

-G Secondary group id

-g primary group id

-d home directory

-c comment

-s shell

-o overwriting the id

  1.  useradd user1 user1 is created
  2.  useradd -u 1001 -d /anydirectory -s /bin/sh user2

user2 is created with uid=1001,home=/anydirectory,shell=/bin/sh

All of user information is stored in /etc/passwd file. It contains 7 fields:

user1:x:500:500::/home/user1:/bin/bash

1 2 3 4 5 6 7  – 7 fields

1 user login name

2 mask password

3 uid

4 gid (primary group id)

5 comment (bydefault no comment)

6 user’s home directory

7 user’s login shell

After creating users we can modify its properties by using usermod:

syntax. # usGermod <options> <username>

options are:

all of the options which are used with useradd command and,

-l to change login name

-L to LOCK account

-U to UNLOCK account

1:  usermod -l newname oldname

2:  usermod -L newname

3:  usermod -U newname

Note:- when a account is locked it will show !(exclamation mark) in /etc/shadow file.

To set password:

syntax. # passwd <username>

  1. 1 # passwd user1

enter the password

re enter the password

  1. 2 # passwd root

enter the password

re enter the password

To delete a user account:

Syntax –  userdel <option> <username>

Examples :

  1.  userdel user1

it will delete user1 but home directory will not be delete

2.  userdel -r user2

it will delete user2 and home directory will also be deleted

Author: Khaja Ehteshamuddin

I am a Linux admin who believes in Hard work, Likes to share knowledge with others. At present I work as Sr. System Administrator at Hyderabad

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s