Skip to main content

Command Palette

Search for a command to run...

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

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

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops

• 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.

90DaysOfDevops

Part 46 of 49

So In This Series I am following 90 DaysOfDevops challenge , what i will learn in my devops journey i will share with you with my blogs ,You will get blog on tools which used by devops engineer , example :- Linux,ansible,terraform,docker,etc

Up next

Day 3 :- Basic Linux Commands with a Twist 🐧💻

DAY 3 :- TASK 1. View the content of a file and display line numbers. cat -n #filename 2. Change the access permissions of files to make them readable, writable, and executable by the owner only. chmod 777 #filename 3. Check the last 10 commands...

More from this blog

A

Anand Raval

118 posts

Hello I am Anand Raval , i contributed my work in robotics(arduino uno) , fronted web devloper,competitive programming, now currently focusing on #90DaysOfDevops