File Permissions
Understanding File Permissions
File permissions can be viewed by using the ls -l
commands in a directory.
Permission Breakdown
There are generally three types of file permissions in Linux, with the exception of Special Permissions which this guide will go over later. Those commands are:
Read: The ability to read the file
Write: The ability to write to the file
Execute: The ability to execute the file ( given it's and executable file )
These permissions when listed will be abbreviated ( r, w, x ) or just a dash if they are not available for the file type.
Lets take for example the above permissions output of -rw-r--r--
. The first -
in the output tells us that the file has no special permissions. If it was a directory the first character would be a d
and would look like drwxr-xr-x
.
The next three characters specify permissions to the current user that you are logged into. In this case these are rw-
meaning that you have the ability to read, and write to the file. However, the third is a minus because the file is not an executable.
The next set refers to the group permissions. In Linux there are users, and each user belongs to a group. You can see the user and group after the permissions. In this case we are the user: user
and are part of the group user
. The permissions for the user
group are r--
meaning the file is only readable to the user
group.
The last set refers to everybody else outside of the groups. The permissions for everyone else in this case are the same as the groups permissions r--
.
Changing Permissions
Permissions for directories and files can be changed by the owner. The command to change permissions is CHMOD
. CHMOD uses a system of numbers to determine the new permissions. The number system looks like this:
4 - Read
2 - Write
1 - Execute
As we went over before there are 3 columns of permissions: User, Group, Everyone. So using CHMOD we'll need to specify permissions for each. Permissions are adding together using the number system such as: rw
would equal 6
. All permissions would equal 7
.
Setting up the same permissions as the example earlier would look like:
Last updated