File Permissions in Linux

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

File Permissions in Linux

Q1. How to create file permissions?


Q2. How to Check the Permission of Files in Linux
Q3. What are the three permission groups in Linux?
Q4. What are the three kinds of file permissions in Linux?
Q5. Reading the Security Permissions in Linux
Q6. How to Change Permissions in Linux
Let’s dive deeper one by one,
Q1. How to create file permissions?
It will set the boundaries for User, Group, Other User by setting up the only required
permission to them so that the any file or any directories will not be affected.

r (Read) w (Write) x (Execute) Permissions


0 0 0 0 ---
1 0 0 1 --x
2 0 1 0 -w-
3 0 1 1 -wx
4 1 0 0 r--
5 1 0 1 r-x
6 1 1 0 rw-
7 1 1 1 rwx

Q2. How to Check the Permission of Files in Linux


“ ls – l “

What is the meaning of this following line.

1
1. First character ‘-‘, which means it’s a file ‘d’, which means it’s a directory.
2. The next nine characters (drwxr-xr-x) show the security.
3. The next column shows the owner of the file.
4. The next column shows the group owner of the file.
5. The next column shows the size of the file in bytes.
6. The next column shows the date and time the file was last modified.
7. Last Column = File_name or Directory_name. (For example, here are: prac, snap, test,
example)
Q3. What are the three permission groups in Linux?
Look at those nine characters as three sets of three characters. Each of the three “rwx”
characters refers to a different operation you can perform on the file.
Owners: These permissions apply exclusively to the individuals who own the files or
directories.
Groups: Permissions can be assigned to a specific group of users, impacting only those within
that particular group.
All Users: These permissions apply universally to all users on the system, presenting the
highest security risk. Assigning permissions to all users should be done cautiously to prevent
potential security vulnerabilities.

rwx rwx rwx


user group other

Q4. What are the three kinds of file permissions in Linux?


Three kinds of file permissions in Linux Read, write, and execute.

Letter Definition
r “read” the file’s contents.

w “write”, or modify, the file’s contents.


x “execute” the file. This permission is given only if the file is a program.

Symbols: `+`, `-` and `=`Option in Linux File Permission


Operators Definition

2
`+` Add permissions
`-` Remove permissions
`=` Set the permissions to the specified values

Q5. Reading the Security Permissions in Linux


For example: “drwxr-xr-x
“d”: It represents a directory.

“rwx“: the first three characters `rwx`. This means that the owner of the file can “read” it
(look at its contents) and “write” it (modify its contents) and execute it.
“r-x” : the second set of three characters “r-x”. This means that the members of the group can
only read and execute the files.
“r–x“ : The final three characters “r-x” show the permissions allowed to other users who have
a UserID on this Linux system. This means anyone in our Linux world can execute the files’
contents.

Q6. How to Change Permissions in Linux?


The command you use to change the security permissions on files is called “chmod“, which
stands for “change mode” because the nine security characters are collectively called the
security “mode” of the file.

How do I change file permissions in Linux using the command line?


To change file permissions in Linux, you can use the `chmod` command followed by the
desired permission settings.
For example: If we want to grants read, write, and execute permissions to the owner, and read
and execute permissions to the group and others.
“chmod 755 filename”

3
4

You might also like