0% found this document useful (0 votes)
17 views5 pages

EXP 03 Part (A)

Uploaded by

siyalohia8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

EXP 03 Part (A)

Uploaded by

siyalohia8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

User and group management:

A> Creating and managing users and groups using user add, userdel, groupadd and passwd.

B> Controlling Access to Files with Access Control Lists (ACL) using chmod, chgrp and chown.

A> Creating and managing users and groups using user add, userdel, groupadd and passwd.

1. What is a User in Linux?


A user is simply an account created in the system.

Every person who wants to use the computer or server gets a user account.

Each user has:

A username (like rajat, admin)

A UID (User ID) → unique number that identifies the user

A home directory (like /home/rajat)

A default shell (like /bin/bash

Why we need users?

To separate files and settings of each person.

To secure the system (one user cannot access another user’s private files unless allowed).

User (UID): your identity (e.g., rajat, UID like 1001).

Key files:

/etc/passwd (user list),

/etc/shadow (password hashes),

/etc/group (groups).
Check yourself: id, whoami, groups.

Most useful options (Debian/Ubuntu shadow-utils):

-u UID, --uid UID → custom numeric UID.

-s SHELL, --shell SHELL → login shell (e.g., /bin/bash, /usr/sbin/nologin).

-u UID, --uid UID → custom numeric UID.

2. Check All Users on the System


All user accounts are stored in the file

/etc/passwd.

cat /etc/passwd

Check If a Specific User Exists

id {username}

3) useradd — Create a user


Purpose: Create a local user account (entries in /etc/passwd, /etc/shadow, /etc/group if needed).

Basic syntax:

sudo useradd [options] USERNAME

Most useful options (Debian/Ubuntu shadow-utils):

-m, --create-home → create /home/USERNAME from /etc/skel.

-d PATH, --home PATH → custom home directory.

-u UID, --uid UID → custom numeric UID.

-U, --user-group → create a private group with same name as user (Ubuntu default style).

-e DATE, --expiredate DATE → account expiry (YYYY-MM-DD).


4) passwd — Set/Change user password
Purpose: Set, change, lock/unlock, and force reset of passwords (updates /etc/shadow).

Syntax:

sudo passwd USERNAME

Useful options (admin side):

-l → lock account (disables password login).

-u → unlock.

-e → expire immediately (forces change at next login)

-d → delete password (no password set; may disable login).

-x DAYS max days, -n DAYS min days, -w DAYS warn before expiry.

Examples:

sudo passwd rajat # set/replace password


sudo passwd -l rajat # lock account
sudo passwd -u rajat # unlock account
sudo passwd -e rajat # force change on next login

Why/when: Secure accounts, rotate credentials, or temporarily block access.

4a) For New user add:(new user)


Sudu useradd username

What is a Password in Linux?


A password protects a user account.

Without the correct password, you cannot login as that user.

Passwords are stored in encrypted form in the file /etc/shadow.

4b)Pass set:for (new user)


Sudo passwd username
{set password}
# give a strong paswd

5)Change user :
Su(switch user)
su username

$ (exit for exit from current user)

SHOW USER
cd /
Ls
Cd /etc
Ls
adduser.conf hosts passwd group shadow ssh ...

cat /etc/passwd
rajat:x:1001:1001:Rajat Kapoor:/home/rajat:/bin/bash

6)For delete user


First go on Home directory
Syntax for User del :
sudo userdel {username}

7) userdel — Delete a user


Purpose: Remove the account entry; optionally remove home..

Syntax:

sudo userdel [options] USERNAME

Important options:

-r, --remove → remove home directory.

Examples:

sudo userdel rajat # remove account only


sudo userdel -r rajat # remove account + /home/rajat
8) What is a Group in Linux?
A group is a collection of users.

Groups are used to manage permissions more easily.

Why we need groups?

If 10 students need access to one folder, instead of giving permissions one by one → just create a
group (e.g., SECTION-A,B,C) and add them.

Makes management faster, cleaner, and secure

Group (GID): a set of users (e.g., students).

Syntax:

Sudo groupadd {groupname}

Check group:(in home directory)

Cat /etc/group

Check user details:

Cat /etc/passwd

9) DELETE GROUP:
sudo groupdel {groupname}

You might also like