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?

1
  • 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 Jan 12, 2022 at 8:47

1 Answer 1

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

You must log in to answer this question.

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