Give Permissions to a File in Linux  Step by Step Guide ▷ 2021

The Linux distribution security is one of the most popular and important points for its users, as it provides great control over which programs interact with which folders and files via the “chmod” permissions.

It is one of the more practical ways that Linux offers us to protect our files, by allowing us to designate the permissions to define who can access, view and edit our files.

Knowing how to operate these permissions from your Linux distribution, it will be a great step in improving the security of your information. To learn everything you need to know about permissions “chmod”, read on to be a pro on this operating system.

What are permissions in Linux and what types can be assigned to files so far?

File Explorer on Linux

The “chmod” function is one of the most effective and used when managing folder access permissions, Linux servers and files. Basically all Linux distributions use these permissions to manage access to their folders. These permissions are assigned to different types of users, which are divided into three groups, according to the three usable digits in a chmod command.

These particular groups are as follows:

  • Owner: is the creator of the file or folder.
  • Group: modifiable parameter where we will decide who has access to the files.
  • Others: includes private users.

To get to the permission numbers in the chmod command, keep in mind that each permission has a particular value assigned within the command syntax.

With this information, the values ​​of each permission are assigned as follows:

  • Reading (r): 4
  • Writing (w): 2
  • Execution (x): 1

With this information, we must learn to add and manage the values ​​of each permission, with the aim of using them in a more efficient way. For example, a read and execute permission would equal 5 (4 + 1), chmod permission commands are executable from the Linux command console, and there are various types and combinations that grant different permissions for files and folders.

The most frequently used chmod permission types are:

  • chmod 777: this permission enables all users to read, write and execute the file or folder.
  • chmod 644: this permission disables the ability to write and read the file or folder for all users except the owner.
  • chmod 755: removes execute permissions for all users. Both the other users and the owner will be able to read and write, but only the owner will be able to execute the file or folder.
  • chmod 700: removes all share permissions on the file for users. Only the owner will keep the permissions to read, write and execute the file.
  • chmod 666: This option enables read and write permissions for all users. Only the owner will have execute permissions.

Commands for assigning and managing permissions in Linux What are they and how is each different?

Command console with Linux chmod settings

A chmod command is used in Linux to access and modify the permissions of a file or folder. Its name is short for “change mode”, that is, change mode in English.

In Linux, the options for setting the security parameters of files and folders are closely related to the specific value that each permission has, and its combinations of use, as follows:

  • 0 = --- : no access
  • 1 = --x : execution
  • 2 = -w- : writing
  • 3 = -wx : writing and execution
  • 4 = r-- : reading
  • 5 = r-x : reading and execution
  • 6 = rw- : Reading and writing
  • 7 = rwx : read, write and execute

This list shows the types of permits assigned to each number, where “R” represents read permission, “W” write permission and “X” the execution of the file or folder. The combination of each value allows giving or restricting the freedoms and access to certain files to the different types of users.

Learn step by step how to give permissions to a folder in Linux correctly with the CHMOD command

Give permission to all users on Linux

Use a chmod command on Linux it’s pretty straightforward.

It is used exclusively through the command terminal, to enter it, it follows a very simple syntax, described below:

  • Chmod tipo de permisos ruta del archivo

Using this training, In conjunction with the command types, we can manage the access permissions of a file or folder by specifying the path of the element that we want to modify.

To manage the permissions of a file for all users, all we have to do is open the terminal and enter the command, which would be a combination of the permission numbers, using them in conjunction with the syntax seen above:

  • Chmod 777 /home/InternetPasoaPaso/InternetPasoaPaso.docx

Through this command, we grant all users read, write and execute permissions to file “InternetPasoaPaso.docx”.

On the contrary, to remove these permissions for all users, except the owner, use the following command:

  • Chmod 666 /home/InternetPasoaPaso/InternetPasoaPaso.docx

In this way, all permissions to modify, read and execute will be removed the file for all users, leaving the file under the exclusive control of its owner.

If you have any questions, leave them in the comments, we will answer you as soon as possible, and it will also be of great help to more members of the community. Thanks! 😉

Author: Mario José

Graduated in journalism, specialized in investigation, I seek the truth of all things. Now 100% focused on technology, computing and Internet issues.

You may be interested:

Rate this post

Leave a Comment