Chmod or how to modify the permissions of our files

Padlock representing file permissions

In many cases, when we want to access a file that has been passed to us through a USB stick or the Internet, or when we want to access a folder belonging to another user, the Gnu / Linux distribution gives us an error. This can happen even if we write the command correctly, what's more, despite this, the system will give us the message of "wrong access" or "access denied".

The reason for this is that in Gnu / Linux both files and folders have permissions to be able to work with them. These permissions are related to the modification, elimination and creation of them.

What are file permissions?

On all Gnu / Linux distributions There are two types of users, mainly, the administrator or root and the rest of users. The administrator has access to all the files of the operating system, he can delete, create and modify any file.

The rest of users can only delete, modify or create their own files, the files that are inside your home. System files and files of other users can only be deleted, modified or created with the permission of the administrator or the affected user.

What permissions can we apply within Gnu / Linux?

Every Gnu / Linux file has three groups of permissions, the first group tells us what the owner of that file can make. The second group tells us what permissions all users of the group that file belongs to have and the third group indicates the permission that other users have.

These permission groups are important since they are played with and allows us to give security and functionality to our operating system.

Thus, we can make certain files can only be read or modified by ourselves, we can make a folder is managed by a group of users who belong to a department or we can make certain files are managed by all and these are within a wide network allowing the customization of all operating systems sharing several files.

To each of these three groups we can apply or indicate the following variables that tell the operating system if it can be modified, deleted or written. The variables are:

    • R: If this letter appears, it indicates that the file can be read.
    • W: If this letter appears, it indicates that it can be written or modified.
    • X: If this letter appears, it indicates that it can be executed

When variables are numbers

The above letters o variables can be changed by numbers 0 to 7. Thus, the number 0 indicates that we do not have any permission on that file and the number 7 indicates that we have all the permissions of that file. The relationship of the remaining numbers with their meaning is as follows:

# Permissions
     All permits.
6       Reading and writing
      Reading and execution
4       Read only
      Writing and execution
      Writing only
1       Execution only
      No permission

Now that we know the variables to apply to files and what each type of file means, we are going to apply it to our files and to our Gnu / Linux distribution.

Console mode

Being able to apply a certain permission to a file or folder through the terminal or console is very easy. Personally I prefer to use this method over the graphical method but both methods work perfectly.

To apply the modify permissions we have to use the command "chmod". If we own that file, just use the chmod command. If we are not owners then we must first use the "sudo" command.

After invoking the chmod command, we have to indicate the letter or number to apply and the file or folder to which we want to apply the changes in its permissions. Between the chmod command and the variable we will use the sign "+" if we want to add those permissions or the sign "-" if we want to remove them.

To display the file permissions we have to use the command "ls -l". After executing it, a list of files will appear with a series of letters such as the following:

drwxr-xr-x

The first letter tells us if it is a file (-), a directory (d), a special block file (b) or a special character file (c). The next three letters tell us about the owner's permissions, the other three letters tell us about the Group's permissions and the rest of the letters tell us about the permissions of other users. If there is a “-” it means that you do not have that permission. That is, if it only has "rx" it means that it has read and execute permission but does not have write permission.

Graphics mode

To modify the file permissions graphically, we must first go to our file manager. Within the file manager we have to select the file that we want to modify its permissions and we click with the right mouse button. Within the menu that appears, we select the Properties option. Then a window like the following will appear:

Screenshot to apply permissions to files

Within this window we go to the "Permissions" tab and we will see all the types of permissions that the file has. Thanks to the dropdowns we can modify the options and make the others have access to "read and write" or none. Also, at the end, the option to "allow the file to run as a program" appears. By marking it we will be making the desktop recognize the file as an executable file. After leaving the changes we want to make, we press the close button and the changes made will be applied.

It may be that we want to change the permissions of a file of another user or files that belong to the administrator. In this case we have to run file manager as administrator.

To do this we open the terminal and write:

sudo “nombre del gestor de archivos”

A window will open with the file manager that will allow us to make any changes to the file permissions. This change can be done in the previous way since we will apply the changes as an administrator and not as a user.

Permission problems?

It must be remembered that these changes that we make in the permissions of the files are made from the user's point of view. In other words, our distribution understands that those permissions are held by the user who makes the changes, but not by the rest of the users. If we have more users, those permissions will not apply to those users unless we indicate it.

It is important to know it and also can be applied to all Gnu / Linux distributions, no matter the name of the distribution. Applying changes and permissions to files in Gnu / Linux is very easy and also very important since part of the security of our operating system is based on that.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Adam Isaías Aguilar Ramírez said

    It only tells me that I cannot make modifications because I am not the owner.

  2.   emerson said

    I have multiple hard drives with files, but Linux Mint won't let me copy the files from one to the other
    Security does not matter to me because only I use these disks, how can I give permissions to all of them so as not to have problems in copying files?
    I have read about "chmod 777" but when I put the command in the console it tells me that I am missing an operand
    Could someone give me the dummy syntax?
    Thank you