I was wondering if it was possible to somehow get the contents of a file which you do not have read access to. I first attempted trying to get around the permissions using the inode number of the file, but I was unsuccessful. My teacher made a file which he said he locked up well, but that there were a few ways of getting to its contents. Getting into the file has nothing to do with our assignment, but I was curious as to how this could be done if it could be done. I did a bit of research, and the only post I found relating to this was to grab the inode number of the file, but after doing that, there was not too much more information regarding it. Any savvy bash/Linux users have a solution to do this?


  • 1
    You can't even execute a file you don't have read permissions on, even if you have execute permissions, unless the person who set it up tried really hard Nov 2, 2018 at 20:25
  • @jeremysprofile The 'file' commands specifies that the file is setuid executable, regular fie, no read permission. The permissions are as follows: -rws--x---
    Nov 2, 2018 at 20:38
  • 1
    @jeremysprofile, of course you can execute a file without read permission, provided it's a binary executable, not a script. Try something like cp /bin/ls ./ls; chmod 111 ./ls; ./ls -l ./ls
    – ilkkachu
    Nov 2, 2018 at 20:59
  • @ilkkachu, you're right, I should have specified. I didn't make that distinction as reading a binary executable is generally not valuable. Nov 2, 2018 at 21:52
  • 1

1 Answer 1


NO. Unlike executable binary output, the binary loader is a special beast with privs to read files and set them into execution. Thus for binary files EXECUTABLE access is sufficient to get the program read and executed.

However, a shell is only an interpreter and does not have such special abilities, and as a typical progam without any special abilities, must read a file. Thus READ access is required for a file to be "input" to a shell command processor.

  • When I run ls -l <file> the permissions come back as: -rws--x---.
    Nov 2, 2018 at 20:47
  • @user3657449 It is possible to execute a file to which you don't have read permissions provided that it's not a script or otherwise interactive. That file has setuid which means that it will run with the permissions of the owner. Nov 2, 2018 at 21:21
  • @NasirRiley Is there a way to piggyback on this permission to output all commands run in the script to the standard output?
    Nov 2, 2018 at 21:38
  • @user3657449 If it's a binary then you can use strace to see the system calls. If it's a script then it won't be possible because it won't run due to your inability to read the file. Nov 2, 2018 at 21:41
  • @user357449 - if it is a script, all you would have to do is cat scriptname since all shell scripts have to have READ access.
    – mdpc
    Nov 2, 2018 at 21:41

You must log in to answer this question.

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