4

I want to fix permissions on another disk with chown. Set the permissions to a user which does not exist on the system which is currently running.

Does that work without adding the user?

  • In my case, I was using chown with $USER:(id -n $USER) that fills the group. But the group had whitespaces so I had to surround the group part. $USER:"(id -n $USER)" worked for me – José Manuel Blasco Jan 12 '22 at 08:47

1 Answers1

6

Use the numerical UID/GID instead of the user/group name.

You can find the UID/GID on the system the disk belongs to by using

  id some_username

or

ls -ln some_file

where some_file is a file that belongs to user you are looking for

Assuming the Group ID is 100, you can now recursively set ownership of a directory to this group ID like this:

sudo chown -R :group_id path/to/dir

in this case:

sudo chown -R :100 path/to/dir