Assigning and removing file access permissions

In a previous post weve look at the different types of access (privileges) different users of a Linux system have. When every file is created therere some permissions that are automatically assigned by the system to such file and they include read, write and execute permissions. The following table summarizes the permissions available for files and directories.

Access type Symbol What is permitted on a file What is permitted on a directory
Read r Allows you to display, copy and compile the file Allows you to list the content of the directory.
Write w Allows you to edit, rename and move the file to another location
  • Allows you to create new files and subdirectories within this directory.
  • Rename files/subdirectories in the directory.
  • Move files and subdirectories to and from the directory.
  • Remove (delete) files or subdirectories from the directory.
Execute x Allows you to execute the file provided the file also has the read permission
  • Allows you to move to the specified directory us the cd command.
  • Display a file in the directory.
  • Copy a file from the directory.

To view the file permissions, used the ls –l command. The file permissions are displayed in the first column of the output of that command. And when you take one line from that column it looks like this;

The first three show the read, write and execute permissions (in that order) for the file owner. The next are the permissions for the group owner, and the last three are the permissions for other users. When there is no permission, a dash or hyphen (-) is displayed.

How to change file access file permissions

The command to do this is the chmod command. And remember only a file owner can change the permissions associated with it (except maybe if you the root or system administrator). There are two ways of changing permissions in Linux; either you use symbols (the use of letters to specify different permissions and user) or numbers (the absolute way). Both method would be explained below.


Therere about four things you require to change the permission of a file using this method;

  • The category of the user (u, g, o or a) for whom the change is needed.

  • The type of permission (r, w or x) to be changed.

  • Whether the permission is being given or revoked (+ or ).

  • The name of the file for which the permission is to be changed.

Lets create a file and then manipulate the permissions associated with it.

Touch newFile

Ls –l newFile

-rw-r–r– 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

chmod u+x newFile

Here the u indicates the file owner, +indicates that the permission is to be given, x indicates the execute permission, and newFile is the filename. After entering the command, the permission would now become;

-rwxr–r– 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

Yeah, simple right. Let say we want to remove the read permission from the group owner we do;

chmod g-r newFile

Here, g indicates the group owner, and indicates that the permission is to be removed. The permission would now become;

-rwx—r– 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

To remove, the read permission for other users we do;

chmod o-r newFile

Then the permission would now become;

-rwx—— 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

Linux also allows the file owner to change permissions from all users for a file, just like this;

chmod a-x newFile

Here, a indicates all users. The execute (x) permission is removed from all the three user (file owner, group owner and others), then the newFile permissions becomes;

-rw——- 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

For the moment try to play with this by added and removing permissions as you like to just get a feel you know.


In this method a series of digits is used to represent actual permissions of files and directories. For you to change file permissions all you need to do is to manipulate these digits. It is considered a more convenient way of hanging permissions since you can specify different permissions for all type of users at a go simultaneously.

The absolute numbers for each type of permission is are;

4 = Read

2 = Write

1 = Execute

This is depicted below;

So let try to do the things we did with the chmod command above.

Using the permission we have when we created the newFile above;

-rw-r–r– 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

From the above we can see that the absolute number of permission for the is 644 (i.e. r+w=6, r=4 and r=4)

Lets assign execute command (represented by 1) to the file owner;

chmod 744 newFile

Since the execute permission is 1, adding it to the file owner increases it to 7, and the group and other user remain 4 each (which is just read permission).

To remove the read permission of the group user we do;

chmod 704 newFile

And also to remove the read permission for other users do;

chmod 700 newFile

And the final permission we get should be;

rwx—— 1 alexander XEROXOFT 0 2016-05-24 06:02 newFile

Yeah, thats it, so churn on that for a little bit. Till then.

Happy LinuxNG!




Chief Editor/Founder at FossNaija
A Linux enthusiast with a focus on enriching the Nigeria Linux experience and keeping a keen eye on Ubuntu and other Foss related developments.
READ  MORE or LESS: Displaying Contents Page-Wise

2 thoughts on “Assigning and removing file access permissions

  1. Maynard

    I see you don’t monetize your website, there is one cool method to earn extra income, it will work with your page perfectly,
    just search in google for; tips and tricks by Fejlando


Tell us what you think

This site uses Akismet to reduce spam. Learn how your comment data is processed.