Day 4 [Part :- 1] :- Managing Users, Groups, and File Permissions in Ubuntu: A Comprehensive Guide

Day 4 [Part :- 1] :- Managing Users, Groups, and File Permissions in Ubuntu: A Comprehensive Guide

• How to add User ?

sudo adduser #user_name

• How to Check User added or not ?

sudo cat /etc/passwd

• How to add password ?

sudo passwd #username

• How to Check user property?

sudo cat /etc/passwd | grep "#username"

• How to switch user?

su #username

• How to exit from user?

exit

• How to delete user?

sudo userdel #username

user deleted or not ? let's check it

sudo cat /etc/passwd

• How to change user login name?

sudo usermod -l #newname #existance_user_name

• What is group?

a group is a collection of users that share the same permissions and access rights to files, directories, and other system resources. Groups are used to simplify the management of user permissions. Instead of assigning permissions to each user individually, you can assign permissions to a group, and all users in that group will inherit those permissions.

For example, if you have a group called "developers" and you want all members of this group to have access to a specific directory, you can set the permissions for the directory to allow access to the "developers" group. Any user added to the "developers" group will automatically have access to that directory.

Note :- If you add user then that will automatically add in group for example create user and check sudo cat /etc/group command you will get user name in group section

• How to add group?

sudo groupadd #groupname

• How to delete group?

sudo groupdel #groupname

• How to add user in group?

sudo usermod -aG #grou_name #user_name

• How to check group property ? or group created or not ?

sudo cat /etc/group

• How to check group admin property ?

• How to Remove group member ?

sudo gpasswd -d #user #group

• How to make group admin ?

sudo gpasswd -A #username #groupname

• How to add single member in group ?

sudo gpasswd -a  #username #groupname

• How to add multiple member in group ?

sudo gpasswd -M #username1 #username2 #group

• What is file permissions ?

file permissions determine who can read, write, or execute a file. These permissions are represented by a combination of letters and symbols and are divided into three categories: owner user, group, and others users.

  1. Owner user: The user who owns the file.

  2. Group: The group that owns the file.

  3. Others users: All other users.

Each category has three types of permissions:

  • Read (r): Permission to read the file.

  • Write (w): Permission to modify the file.

  • Execute (x): Permission to execute the file (if it is a script or a program).

The permissions are displayed using the ls -l command, which shows a string of 10 characters. For example:

You can see in this image drwxrwxr -> in there d stand for directory and if there is (-) means it is a file

Truth table for permission:-

1 means ture and 0 means false

how to change file permission

chmod 777 #filename/directoryname

Thank you for reading!

© 2024 Anand Raval. All rights reserved.