Linux file system permission
In linux , to increase the security of the file and directory. we need to used permission. There are total three type of file permission are Read , Write , Execute.
There are three type of file permission are as follow:
- user ( u ) : Permissions used for the user of the file.
- group( g ) : Permission used by the group member.
- other (o) : Permission used by all other users.
For example, suppose a file has read permissions that are allowed for the user. In this case, the user can only read that file, while the group and others will not be able to read it.
1 . `ls -ld` it is used to check the permission of directory
ls -ld
Permission |
Access for a file |
Access for a directory |
---|---|---|
Read (r) |
display file contents and copy the file |
view contents of directory |
Write (w) |
modify the file contents |
modify the contents of a directory |
Execute (x) |
execute the file if it an executable permission |
allow use of cd command to access the directory |
Permission with numeric & symbol
Number |
Permission Type |
Symbol |
---|---|---|
0 |
No permission |
— |
1 |
Execute |
–x |
2 |
Write |
-w- |
3 |
Execute +Write |
-wx |
4 |
Read |
r– |
5 |
Read + Execute |
r-x |
6 |
Read +Write |
rw- |
7 |
Read + Write + Execute |
rwx |
2. chmod This command is used to change the permission of file and directory.
chmod <permission of user , group , other> {filename }
3. chown : It is used to change the owner of the file and directory.
chown [owner_name] [file name]
4. cat : it is used to read and concatenate the text inside the files. with help of this command we can displays the content inside the file.
cat <flag> {filename}
Command |
Description |
---|---|
cat -b |
This flag adds number to the text line. |
cat -E |
This flag add $ at the end of each line. |
5. Grep (Global Regular Expression Print) : It filter searches a file for a particular pattern of characters , and displays all lines that contain the pattern.
grep <flag or search_word> {file name}
Command |
Description |
---|---|
grep -i |
Delivers results for case-insensitive strings. |
grep -n |
Retrieve the corresponding strings and their respective line numbers. |
grep -v |
Provides the output of lines that do not contain the search string. |
Linux command in DevOps
Linux fundamentals are crucial skills for a DevOps professional. Through this article, we will learn about all the required Linux commands which we will frequently use in a DevOps career.