Linux – Write but not read permission on a file in linux

filesystemslinuxpermissions

Is it possible to have write but not read permission on a file in Linux?
What about execute but not read and write permission?

Best Answer

Yes, although execute permission without read permission is meaningless on a non-binary file (since you need to read a script to execute it). On a directory, execute without read means you can traverse the directory, but not list it or do anything else with its contents. Consider the following path:

/home/user/foo/bar

If directory foo has mode 0711 (full permission for owner, execute only for group and world), while directory bar has mode 0755 (full permission for owner, read and execute for everyone else), then accounts other than user may cd /home/user/foo/bar and find that bar behaves as any ordinary directory; however, while cd /home/user/foo will work, ls and any other command in that directory will fail due to insufficient permissions (i.e., you can't read the directory to list its contents).

Write permission without read permission on a file does just what it implies: you can write to the file, but you can't read back what you've written. This might be useful in a case where processes under multiple accounts write to a single logfile, but a process belonging to one user must not be able to read the (presumably sensitive) log entries from a process belonging to another user.