What does `chown root.root $file` mean?

16,288

Solution 1

It sets the user and group of $file to root (as in chown OWNER.GROUP FILE...). It's the same as calling chown root:root $file, but an older form.

The period was replaced by a colon, giving chown OWNER:GROUP FILE... as documented, because periods could potentially appear in user/group names.

Solution 2

"chown user.group file" was the old way to use chown to set both user and group for a file. This notation is now deprecated, and you should use ":" instead, as in "chown user:group file".

"$file" is just shell-variable. Probably you have a script that repeats a command (chown) for a list of filenames. The variable "$file" will contain the filename currently being processed, and will change for each "round" the script iterates, until the list (all the filenames) has been processed (have gotten their owner and group set to root:root).

Share:
16,288

Related videos on Youtube

RSFalcon7
Author by

RSFalcon7

Updated on September 18, 2022

Comments

  • RSFalcon7
    RSFalcon7 almost 2 years

    I'm trying to install colordiff in a custom directory because I do not have sudo privileges. I did make the directories hard-coded in the Makefile as stated in the README, but I'm getting this error:

    ...
    chown root.root /share/edu-mei/colordiff/1.0.13/etc/colordiffrc
    chown: changing ownership of `/share/edu-mei/colordiff/1.0.13/etc/colordiffrc': Operation not permitted
    make: [install] Error 1 (ignored)
    ...
    

    Changing this file ownership is not really a problem (probably the reason that the author ignores this). However I'm not familiar with this usage of chown.

    The manpage from chown says that the command syntax is:

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

    But the command executed is chown root.root $file.

    What does the syntax with a dot rather than a colon mean?

    • TNW
      TNW about 11 years
      Dot instead of colon is also valid. I think that's about it.
    • depquid
      depquid about 11 years
      The answers below explain the syntax, but this command fails because as non-root, you can't change ownership to root.
    • RSFalcon7
      RSFalcon7 about 11 years
      @depquid that was easy to figure out with the syntax clarified. After all, my question weren't about the error.
  • RSFalcon7
    RSFalcon7 about 11 years
    $file is my own way to express the filename
  • camh
    camh about 11 years
    It should be noted for completeness that the reason a colon is used is that it cannot appear in a user or group name, as described here: unix.stackexchange.com/a/6531/1078
  • n611x007
    n611x007 about 10 years
    as documented could you give a link? also android seems to use dot and reject colon, which is also unclear why.