Day 4 [Part :- 1] :- Managing Users, Groups, and File Permissions in Ubuntu: A Comprehensive Guide
Table of contents
- • How to add User ?
- • How to Check User added or not ?
- • How to add password ?
- • How to Check user property?
- • How to switch user?
- • How to exit from user?
- • How to delete user?
- • How to change user login name?
- • What is group?
- • How to add group?
- • How to delete group?
- • How to add user in group?
- • How to check group property ? or group created or not ?
- • How to check group admin property ?
- • How to Remove group member ?
- • How to make group admin ?
- • How to add single member in group ?
- • How to add multiple member in group ?
- • What is file permissions ?
• 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.
Owner user: The user who owns the file.
Group: The group that owns the file.
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.