Skip to content
Step by Step Internet 🌐 Guides for learning to surf the Net
iOS

How to modify permissions and owners in Linux operating system? Step by step guide

Operating systems like Windows, are very popular with home computers. Similarly occurs with ios but in different segments. However, when it comes to servers, Linux is among the best options.

This is because it has a optimized performance for that end. At the same time offering integrated services and ready to use in the cloud. Moreover, all administrative tasks can be performed from the same console.

However, before you start using this OS, it is important that you know which is the correct way. For this we offer you this chapter within the Linux Course in which you will learn how to modify the permissions and owners.

What should we keep in mind when changing permissions and owners in Linux?

It is important that you remember that every time we create or activate a user in Linux, it has certain privileges. They are not absolute and are inferior in comparison to those of a Super user. By default, the system gives this new user the ability to handle files and directories.

This is defined individually in each file and file. This feature is referred to as permissions. Sayings permits they can be modified. That is, they can add or remove capabilities to a user about a document or set of them. This task can only be performed by the administrator or root.

Learn step by step how to modify permissions and owners in Linux

Learn step by step how to modify permissions and owners in Linux

In this Step by Step, we can know how to change the permissions that users have on a file or folder. But we will not just stay with it, but we will also learn what functions each element fulfills in the command syntax. The first thing we must do is identify the permissions that a document has.

To do this, we must open the command line and type “Ls -l” (Lowercase L) followed by the file name. For example, for the text document named “Document1” it would be “ls -l document1.txt”. After this, something similar to “-Rwxrwxr-x 1 user user 0 Jan 19 12:59 document1.txt”. These are the meanings of each letter that appears on the line.

The first character identifies the type of file:

  • “-“ Archive.
  • “D” Directory.
  • “B” Special blocks (Device special files).
  • “C” Special characters (tty device, printer, etc.
  • “L” Links file (soft / symbolic link).
  • “P” Channel special file (pipe).

He rest of the set of letters is divided into three blocks. He First of them refers to owner, he second to the group owner and the latest to the rest of users who do not belong to any of the former.

The letters in each group mean what appears below:

  • “-“ Without permission. You cannot perform any of the actions which are named below
  • “R” Read permission. Basically display only
  • “W” Write permission. May Modify the content.
  • “X” Execution permission. May run the program if it were one.

Continuing with the example we show, we can distinguish that, the owner of the file (-) has full access to it (rwx). The same happens with the group (rwx). However, the rest of the users can only read and execute (rx). Alright now that we know how read the permissions of each file, it’s time to find out how modify them. For this we will use the command “Chmod” to change access permissions and “Chown” to modify the owner of a file.

Go for it:

CHMOD

It offers two ways to assign permissions. He symbolic and numerical.

For the first you must know in addition to the letters that we showed before, the following:

  • “or” for user.
  • “G” for group.
  • “or” for those who do not belong to any.
  • “to” for all.
  • At the same time:
  • “+” to add a permission.
  • “-“ to remove it.
  • “=” to assign a new one.

If no letter is added after the symbols, will be taken as negative said property. To establish it more clearly, for example, to define permissions so that only the owner can read, we will write the following “Chmod u = r, g =, o =”.

If instead, we need the owner to have read and write and read only for the rest we will use “Chmod u = rw, g = r, o = r”. The second way to achieve the same result is through the numerical method. Which allows through a value between 0 (or empty) and 8 assign the different permissions. The location of each of them continues to correspond to the type of user.

Each number corresponds to the following permissions:

  • “0” = – = no access
  • “one” = –X = execution
  • “two” = -w- = write
  • “3” = -wx = write and execute
  • “4” = r– = reading
  • “5” = rx = read and execute
  • “6”= rw- = read and write
  • “7” = rwx = read, write and execute

Continuing with the example, we have the command “Chmod 400” means that the file can be read only by the owner. For his part “chmod 644 “ the owner can read and write and the rest can only read. It is important to clarify that leading zeros may not be written.

CHOWN

This command, unlike the previous one, manage the owners and not the characteristics of the document. In this way we can define a user as owner of a specific file.

To explain it in a simpler way, let’s look at the following example:

  • Given the file “Example.txt”, the user “PAP” we should write the command “Chown IPAP example.txt”.
  • It is important to mention that the use of the command “-R” which allows changes to be applied to all files within a file, should be used with extreme caution, andto what to be used incorrectly could affect the operation of the system. Being the method to reverse the action quite complex.