Linux is a multi-user system where the same resources can be shared by different users.
All permissions in Linux are based on restricting access to specific files and folders to specific users or user groups.
Types of Files
Types of permissions
Permission groups
Changing file permission using chmod
Changing ownership
Types of Files
In Linux, total 7 files types are there.
- --> normal file
d --> directory file
l --> link file
b --> block special file
p --> block special file
c --> character special file
s --> socket file
Types of permissions
In Linux, File and Directories have three basic permissions types.
Read Permission (r)
Write Permission(w)
Execute Permissions(x)
Read Permission (r) :
The Read Permission allows you to open and read the content of a file. But you can't do anything.
Write Permission (r) :
The Write Permission allows you to emodify the file and write new data to the file.
Execute Permission (x) :
The execute permission allows the user to execute the file as a shell script or a program.
Types of permissions
In Linux, File and Directories are owned by a specific user and group and are defined separately as three user based permission groups. They are as follows:
From above image :
-rw-rw-r-- this statement we are divide into 4 parts
- --> file type
rw- --> user level permissions
rw- --> group level permissions
rw- --> others permissions
The numbers are a binary representation of the rwx string.
r = 4
w = 2
x = 1
Changing file permission using chmod
if we observe first file3(file name) has 664 permissions are there.. right now, 777 permissions.
Changing Ownership
Change Ownership of the file :
Chown username filename
Change Ownership of the group :
Chown :username filename
Change Ownership of the directory :
Chown username:username directoryname
Change Ownership of the directory along with inside files :
Chown username:username directoryname/
Liked This Article?
Conclusion
Linux as a multi-operating system sets permissions and ownership to ensure security for a file and directories of the users. And it also allows to change and modify the permissions to a set of people as per the requirements.