chown: what you need to know about this permissions command

Chown command

Linux-based operating systems are designed in a way that they can support multiple users. Because of this, these systems must maintain permissions access data for files and directories so that you know who can access them. There are two types of permissions that can be managed with the command chown- User permissions that are designed only for a specific user and group users that are designed for a specific group.

chown used to manage that type of property or permissions. With this command we will change who can access certain files and directories. In this article we will explain everything you need to know about this command, especially useful for shared computers (otherwise it would not make much sense).

How to use chown

Before I begin I would like to remind you that when a file is mentioned, what we mean is the complete route. With this explained, the command syntax is as follows:

chown [Opciones] [usuario_propietario:dueño_del_grupo] [Archivo]

From the above we have to:

  • Options are the different options that we will use with the command.
  • owner_user: group_owner It is in username and / or group name, although the UID (User Identifier) ​​or GID (Group Identifier) ​​can also be used.
  • Archive is the file to which we want to change the permissions, which can be one or more.

How to change the owner of a file or directory with chown

We can change the owner of different files and directories using the command chown. For example, to change the owner of a file to a specific user we will execute the following command:

chown pablinux archivo.ext

From the above, "pablinux" is the user and "file.ext" is the file with its extension.

If we want to change the name of several files, what we will do is add one after the other separated by a space, which would look more or less like this:

chown pablinux archivo.ext archivo2.ext

In the case of the directory, the only thing that we will change is that instead of putting a file we will be able to a directory.

How to change the owner of a file with the UID

The first thing we have to do is obtain our UID with the following command:

echo $UID

The above should result in the number 1000. To change the owner of a file in this way, the command that we would introduce below would be the following:

chmod 1000 archivo.ext

Change the owner and group of a file

To change the owner and group of a file we have to provide it with a username and group name. Using the command chown We can change the owner and the group as follows, first we will change the owner of a file and the group with the following command:

chown pablinux:administradores archivo.ext

The name of the group can be whatever we want; in the example above it would be "administrators". If we do not want to give it a group name at that time we can indicate only the username, for which we would use the colon and then a space as in the following example:

chown pablinux: archivo.ext

In the previous example, by not indicating any group, it will take the user's group, in this case pablinux.

Change the group of a file with chown

We can change the group name of a file using the command chown. The command would look like this, where linuxadictos would be the new group of the file.ext file:

chown :linuxadictos archivo.ext

As you can see, in the previous command the space is to the left of the colon.

Change file owner recursively

Using the -R option we can change the name of the group or the owner of a file and subdirectories that are within a specific directory. In the following command we will change the directory / Var / www a linux addicts:

chown -R :linuxadictos /var/www

How to see the owner of the files

To see who owns a file we can use the command ls with the option -l. For example, to see the owner of the file file.ext we will enter this command:

ls -l archivo.ext

The result will show us something like:

-rw-r--r-- 1 pablinux pablinuxusuarios 241 Mar 1 01:28 archivo.ext


Do you already know how to use the command chown on Linux?


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.



  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.