I don't understand why the permission does not change for a user when I run the chmod command with fakeroot.

Initially, the file has these permissions:

-rwxr-xr-x  a.txt*

When I try to change the permission for the file using chmod it works fine:

chmod 111 a.txt

---x--x--x  a.txt*

When I run it with fakeroot it doesn't seem to do the work fine. It sets the permissions for group and other correctly, but not for the user. The permissions for read and write are set, no matter what the 1st value in chmod command is.

fakeroot chmod 111 a.txt

-rwx--x--x  a.txt*

Am I missing something?

2 Answers 2


Fakeroot doesn't carry out all the file metadata changes, that's the point: it only pretends to the program that runs under it. Fakeroot does not carry out changes that it can't do, such as changing the owner. It also does not carry out changes that would cause failures down the line. For example, the following code succeeds when run as root, because root can always open files regardless of permissions:

chmod 111 a.txt
cp a.txt b.txt

But when run as a non-root user, cp fails because it can't read a.txt. To avoid this, chmod under fakeroot does not remove permissions from the user.

Fakeroot does pretend to perform the change for the program it's running.

$ stat -c "Before: %A" a.txt; fakeroot sh -c 'chmod 111 a.txt; stat -c "In fakeroot: %A" a.txt'; stat -c "After: %A" a.txt
Before: -rwx--x--x
In fakeroot: ---x--x--x
After: -rwx--x--x

Generally speaking, file metadata changes done inside fakeroot aren't guaranteed to survive the fakeroot call. That's the point. Make a single fakeroot call that does both the metadata changes and whatever operations (such as packing an archive) you want to do with the changed metadata.


This is a quirk of fakeroot, required to implement its root-masquerading functionality; as documented in a code comment:

if a file is unwritable, then root can still write to it (no matter who owns the file). If we are fakeroot, the only way to fake this is to always make the file writable, readable etc for the real user (who started fakeroot). Also holds for the exec bit of directories.

So fakeroot always sets u=rwx, and records the real permissions that were requested in its internal state (which you can save to a file with the -s option; the resulting file is human-readable). In fact,

chmod 155 a.txt
fakeroot chmod 111 a.txt

will result in a file with 711 permissions!

You must log in to answer this question.

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