Member-only story
Basics of Linux file permission
Linux is a multi-user operating system and it uses the concepts of “ownership” and “permissions” to enhance the security of the files and directories.
Every file and directory on Linux system is owned by a specific user and group. Therefore, file/directory permissions are defined separately for users, groups, and others.
User: The username of the person who owns the file/directory. By default, the user who creates the file/directory will become its owner.
Group: The user group that owns the file/directory. All users who belong to the group that owns the file/directory will have the same access permissions to the file/directory.
Other: A user who isn’t the owner of the file/directory and doesn’t belong to the same group the file/directory does. In other words, if you set a permission for the “other” category, it will affect everyone else by default. For this reason, people often talk about setting the “world” permission when they mean setting the permissions for “other."
If you want to view the users on your system, you can view the /etc/passwd
file by running the following command:
cat /etc/passwd
Similarly, you can view the groups on your system by viewing the /etc/group
file, by running the following command:
cat /etc/group
Linux use 3 types of permissions as follows,
1. Read
2. Write
3. Execute
- Read permission:-
For a file, the read permission means the file can be opened and read.
For a directory, the read permission means the user can list the contents of the directory.
2. Write permission:-
For a file, write permission means the user can modify the file, and write new data to the file.
For a directory, the write permission means the user is allowed to modify the content of the directory. The user can add, remove or rename files belongs to the particular directory.
3. Execute permission:-
For a file, execute permission means the user can execute the file as a program or a shell script.
For a directory, the execute permission allows the user to access files in the directory and enter it, with the cd command but you are not allowed to list the content.