Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a GNU/Linux OS there is no way to change ownership of a file until you are root. But what if I want to hide my system’s username e.g. before sending a file to someone, because some things like tar will try to keep it?

What I think about is something like

# mkdir --mode=????? /tmp/nobodysfiles
# chown nobody:nobody /tmp/nobodysfiles

$ whoami
$ ls -l ~/file
-rw-r--r-- 1  popcorneater popcorneater 12345 oct.  18 11:10
$ cp ~/file /tmp/nobodysfiles/
$ ls -l /tmp/nobodysfiles/file
-rw-r--r-- 1 nobody nobody 12345 oct.  18 11:11
share|improve this question
If you set permissions on the folder to be g+s, then new files created in that folder will belong to the folder's group. This is just a partial solution, though. You can't similarly change the owner of the file (even if folder permissions are u+s), and files created elsewhere then moved or copied in keep their original owners and groups. Doesn't the tar flag --numeric-owner do what you want, though? – dubiousjim Oct 17 '12 at 21:54
up vote 4 down vote accepted

Prepare your archive inside a fakeroot session. Fakeroot was designed precisely to prepare a directory structure's ownership and permissions before building an archive.

fakeroot bash
chown -R root:root nobodysfiles
tar czf nobodysfiles.tgz nobodysfiles
share|improve this answer
That’s what I need, thank you. – tijagi Oct 18 '12 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.