1. USER MANAGEMENT:
1. For creating a new user account
sudo useradd subhankar-devops -m //it will create a directory inside your home
2. For setting up password for new user:
sudo passwd subhankar-devops
3. To check user added or not or to see all the users:
sudo cat /etc/passwd
2. GROUP MANAGEMENT:
A group is a collection of user accounts that is very useful for administrators to manage and apply permissions on several users.
1. To add a group account:
sudo groupadd deep-devops
2. To see all the groups:
sudo cat /etc/groups
**By default if u add a user by default its group is its user
3. To add any user to any particular group:
sudo gpasswd -a subhankar-devops deep-devops
4. To add multiple users in a group:
sudo gpasswd -M santosh,suraj deep-devops
5. To make group Admin:
sudo gpasswd -A subhankar-devops deep-devops
To remove a user from group:
sudo gpasswd -d suraj deep-devops
3.Linux File System Permission:
File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how.
Types of file permission:
Basic permission
Special permission
Access Control List (ACL) permission
1. To check file permission:
ls -l java
It shows permission, link, owner, group owner, size of the file, date and time of the file, and name of the file.
2. Permissions in detail:
File type: File type defines the type of the file. For regular files that contain simple data it is blank
-
. For other special file types the symbol is different. For a directory which is a special file, it isd
. Special files are treated differently by the OS.How to Read Symbolic Permissions
The
rwx
representation is known as the Symbolic representation of permissions. In the set of permissions,r
stands for read. It is indicated in the first character of the triad.w
stands for write. It is indicated in the second character of the triad.x
stands for execution. It is indicated in the third character of the triad.
4.For Change Permissions:
- To add READ permission to owner:
chmod 400 java ----[4 means read]
2. To give read-write access to user/group:
chmod 660 java ----[66 means read+write]
5.Access Control List (Acl):
ACLs allow us to apply a more specific set of permissions to a file or directory without (necessarily) changing the base ownership and permissions. They let us "tack on" access for other users or groups.
1. To check ACL permission:
getfacl devops
2. To set ACL user permission:
setfacl -m u:python:rwx/devops
3. To remove ACL user permission:
setfacl -x u:python:rwx/devops
4. To remove all ACL permissions:
setfacl -b/devops
6.REGULAR EXPRESSIONS:
These are some special characters that help to find/search data, matching complex patterns.
GREP [Global Regular Expression Print]
The grep filter searches a file for a particular pattern of characters and displays all lines that contain that pattern.
- To search for a word (string in a file)
grep root etc/passwd
2. To search a String in multiple files:
grep root etc/passwd /etc/group
3. To search any particular word:
grep -r qa/ ---[/ means it will search each and every file/directory]
4. To find anything inside logs:
grep RSVPGetTSpec log_file.txt
FIND COMMAND:
In Linux, the FIND command is one of the most important and used command in the Linux system.
The find command helps us to find a particular file within a directory. It is used to find the list of files for various conditions like permission, user ownership, modification, date/time, size, and more.
1. To find everything within the file/directory
find .
2. To find any particular word:
find . log* -----[dot means everything starts with log*]
3. To find all the files present:
find /home/ubuntu -type f
4. To find all directories present or with a particular name:
find home/ubuntu -type d