What is the difference between:

sudo chown $USER:$USER


sudo chown $USER

Why is it 2 times? Is the one user wrong? When I look at permissions with namei -l, I often see things like root root or proxy proxy.

Why does the owner have to be defined and listed 2 times?

3 Answers 3


The chown command is used to change the owner and group owner of a file or directory. Superuser privileges are required to use this command. The syntax of chown looks like this:

chown [owner][:[group]] file...

chown can change the file owner and/or the file group owner depending on the first argument of the command. Here are some examples:

chown owner file example:

chown bob file --> Changes the ownership of the file from its current owner to user bob.

chown owner:group file example:

chown bob:users file --> Changes the ownership of the file from its current owner to user bob and changes the file group owner to group users.

chown :group file example:

 chown :admins file --> Changes the group owner to the group admins. The file owner is unchanged.

chown owner: file example:

chown bob: file --> Change the file owner from the current owner to user bob and changes the group owner to the login group of user bob.

Please read this nice tutorial https://www.linode.com/docs/tools-reference/linux-users-and-groups. This show some info about user, groups ,permissions ,...

  • Thanks. However, what is the benefit to even using groups? Is it that all of the users grouo owns it, not just bob?
    – John K
    May 27, 2015 at 11:44
  • suppose you want to give permission to some users other than the owner!! this is why use groups, you can make a group for them and give it permissions
    – Maythux
    May 27, 2015 at 11:46
  • You need groups mainly on server machines that are used for multiple users. Say you have a server where people working for your company on project a and project b have user accounts. You could now grant permission to the company group for the files everybody needs to access, and set the ownership for all project a files to the group "project a". That way, nobody from project b will be able to access project a files.
    – til_b
    May 27, 2015 at 11:55
  • Groups are needed on desktop too, e.g. for sudo, dialout, scanning, etc.
    – Pilot6
    May 27, 2015 at 11:57
  • If a user is the owner, will sudo ever be needed to execute the file?
    – Matthew
    Oct 11, 2018 at 16:37

It is not user:user, but user:group.

This is command format

chown [OPTION]... [OWNER][:[GROUP]] FILE...

Group of users may include many users. Here is some information regarding groups:

Linux uses groups as a way to organize users. Groups organize collections of accounts, primarily as a security measure. Control of group membership is administered through the /etc/group file, which shows a list of groups and its members. Every user has a default or primary group. When a user logs in, the group membership is set for their primary group. This means that when a user launches a program or creates a file, both the file and the running program will be associated with the user’s current group membership. A user may access other files in other groups, as long as they are also a member of that group and the access permissions are set. To run programs or create a file in a different group, the user must run the newgrp command to switch their current group.

A file is owned by a user and a group. By default it is owned by the user who created the file and his default group, unless it is changed.

In your case user root is a member of group root.

  • What is the difference between user and group? I don't see the difference between root and root root What does group do? I understand the owner section though
    – John K
    May 27, 2015 at 11:42
  • When you add a user to linux, it creates a group with that name. Group contains users. Lets say you have accounting department and you want your account departments to give read write access. You can add all the people to account group and give the read write permission to relevant folder/file.
    – dedunu
    May 27, 2015 at 12:25
  • If you run cut -d: -f1 /etc/group command you can see complete list of groups in your system. unix.stackexchange.com/questions/153390/… might help you to understand why there is a group with username
    – dedunu
    May 27, 2015 at 12:30

man chown gives description and usage and other useful info on chown command.

       chown - change file owner and group

       chown [OPTION]... [OWNER][:[GROUP]] FILE...
       chown [OPTION]... --reference=RFILE FILE...

Form the info given by man page, we may know that chown $USER:$USER changes owner and group of target file to $USER, while chown $USER only changes owner of target file to $USER, leaving group of the target file unchanged.

Details (from man page) follow:

Owner  is  unchanged  if  missing.   Group is unchanged if missing, but changed to
login group if implied by a ':' following a symbolic OWNER.  OWNER and  GROUP  may
be numeric as well as symbolic.

So chown $USER:$USER can be shortened as chown $USER:.

Outputs like root root from namei -l command mean that the owner and group of that file are both set to root. That's not owner defined or listed twice. Owner and group are two related but different concepts. And a file always has a owner and a group.

As to use chown command, great chances are superuser privilege is required, since one is likely to transfer the ownship of a file when using chown command. However, that is not always the truth.

Say, we have a user named 'test', who belongs to several groups. id command gives following output:

uid=1000(test) gid=1000(test) groups=1000(test),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),110(sambashare)

And user 'test' owns the following file:

-rw-r--r-- 1 test test 0 May 27 23:34 test_file

Then we can change the group of test_file to sambashare without superuser privilege, as user 'test' belongs to 'test' group and 'sambashare' group at the same time, user 'test' already owns enough permission to change the group of the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .