Linux

Linux file permissions

Linux file system determines whether or not a user or group can access these resources based on the permissions assigned to them. Every file or folder in Linux has access permissions. There are three types of permissions.
(what allowed to do with a file):
Permissions are defined for three types of users: Use ls -l command to know the file permissions as show in figure below.
Linux file permissions
Linux file permissions

File permissions notation

Textual representation like "-rwxr--r--"
r        Read access is allowed
w        Write access is allowed
x        Execute access is allowed

The "-" replaces "r", "w" or "x" if according access type is denied.
Understanding this representation
Linux file permissions numeric
Linux file permissions numeric

Examples of file permissions

-rwxr-xr-x        File, owner has read, write, execute permissions.
                    group member can only read and execute permissions.
                     others user can only read and execute permissions.
dr-x------        Directory, owner has read and execute access, group and others have no access

Numeric (octal) representation

Numeric octal is ver simple. One octal number combines read, write and excute permissions. Example: "644". Here the first digit ("6" in the example) stands for rights of the owner, the 2nd digit ("4" in the example) stands for rights of the group, the 3rd digit ("4" in the example) stands for rights of others.
This table shows what numeric values mean:
Letter Permission Value
rread4
wwrite2
xExecute1


Octal digitText equivalent Binary ValueMeaning
0---000 All types of access are denied
1--x001 Execute access is allowed only
2-w-010 Write access is allowed only
3-wx011 Write and execute access are allowed
4r--100 Read access is allowed only
5r-x101 Read and execute access are allowed
6rw-110 Read and write access are allowed
7rwx111Everything is allowed

Examples
644
owner: read and write permissions
group: only read permissions
others: only read permissions.

755
owner: read, write and execute permissions,
group: read and execute permissions,
others: read and execute permissions.

Explanation of 773
Linux file permissions numeric
Linux file permissions numeric

I hope you are now able to understand the file permissions.
Explanation of ls -l
Linux file Explanation of ls -l
Explanation of ls -l

1 = Permission
2 = contents of dir/file
3 = user owner
4 = group name
5 = Size
6 = Date
7 = Name of dir/file

Symbolic Method

The symbolic method of setting permissions uses the characters r, w, and x for read, write, and execute, respectively. Any of these permissions can be added or removed. The symbol to add a permission is the plus sign, +. The symbol to remove a permission is the minus sign, -.
Description
r      Read
w      Write
x      Execute (also gives permission to change into a directory)
X      Execute only if it is a directory or has execute permission for some user
s      Set user or group ID on execution
t      Sticky bit
u      Permissions granted to user who owns the file
g      Permissions granted to users in the file's group
o      Permissions granted to owner of the group and users in the file's group
How to use the permissions you will in chmod chapter.




admin