Introduction to Linux File Permission

0

On linux operating system, file permission is a very important issue. As a server system different users need t different kind of permission. More over a user may get permission on a single file and at the same time it may also necessary to give permission on different files depending on the user’s necessity.

On Linux, we can see that a single file can have three types of permissions.

  1. Owner’s permission / super user permission
  2. Group permission
  3. User’s permission.

This same permission scheme goes with folders too. So, as a system administrator it is quite a important matter to handle properly.

Let’s see an example of file permission.

-rwxr-xr-x           1              root       root       size date month year     file path

According to the first column we can see few characters there like rwx. These three means read write and execute. Also we can see that it has three segments. These three segments mean owner, group and user. Now the first three characters belong to owner, the next three characters belong to the group and the last three characters belong to the user. on third column we can see root which is the group owner of the file. On fourth column it means the user of the file. The next column means the size of the file next the date and the year of creation of the file. The last column refers the total path of the file.

Now we need to know about the tools to change the permission and ownership of the files and folders.

-chmod

-chgrp

-chown

These above tools are useful only if we have super user privilege. To get super user privilege we need to learn two more tools.

-su

-sudo

First, we need to gain super user privilege if we do not have more than one or two works than we should gain temporary super user privilege. In that kind of case we usually use sudo. The use of this tool is given below.

#sudo chmod –R 750 file_path.

To get permanent super user privilege we can use SU command. Using this command we can get a permanent privilege until we close the session. The use of this tool is given below.

#su username

Or

#su – username

Now, let’s talk about some details about tools usually used to change the file permission. But before that we need to know how we can represent all those permissions using numeric numbers.

We usually represent permissions using number like below.

Read- 4

Write- 2

Execute -1

The sum of these three permissions is 7, as we know the whole permission have three segments, so 777 is the full permission for any file or directory. If we want to provide full permission to any file or folder then we need to run the below command.

#sudo chmod –R 777 file_path

If we want to check the file permission on terminal then we have run the below commands

#ll file_path

#ls –l file_path

Before we talk about the next tool I would love to mention some commonly used permission representing numbers below.

-rwxrwxrwx    — 777

-rwxr-xr-x      —- 755

-rwxr–r–     —- 744

-rwx——     —-700

-rw-r–r–     —— 644

We have only two tools left to learn about. Here we will discuss about ownership and group modification to change ownership we need to run the below command.

#chown username filename

To change group ownership of a file then we need to run the below command.

#chgrp groupname filename.

There is some special permission left to know. We will learn it on our future articles.

Leave A Reply

Your email address will not be published.