1

Suppose we have a user pepe who has a directory ~/pepe_cant_see in his home directory in which he possesses -wx permissions, and inside of this directory, another directory ~/pepe_cant_see/no_restrictions in which pepe has rwx permissions. Then pepe will be able to cd into the pepe_cant_see directory, but he won't be able to list its contents - so while in theory he can cd into no_restrictions, he wouldn't have any way of knowing that this directory exists or what its name is.

My question is: if I'm in a directory where I lack reading permissions, but there exist other files/directories inside of this directory for which I have full permissions, is there any way to detect their existence? For example, is there a command that will allow me to enter a random/arbitrary directory from my CWD or edit a random/arbitrary preexisting file?

(Note: this is purely out of curiosity, I have no reason to think this kind of thing would ever happen in practice.)

2
  • On what operating system? I doubt it in this case, but there may be differences.
    – terdon
    Oct 23, 2022 at 13:38
  • @terdon I'm working on an Ubuntu 20.04 server. But if there are differences between OSs, I would be interested in hearing about them... Oct 23, 2022 at 13:59

1 Answer 1

0

No. Since you cannot read the directory, you cannot see its contents. This means you also can't use tricks like cd * to match the one directory you could move to because the shell needs to expand * and to do that it needs permission to read, and since it runs under your user with your permissions, it cannot do that:

$ pwd
/home/terdon/pepe_cant_see
$ sudo ls -l .
total 4
drwxrwxrwx 2 root root 4096 Oct 23 14:36 no_restrictions

$ cd p*
bash: cd: p*: No such file or directory
$ cd *
bash: cd: *: No such file or directory
$ cd no_restrictions
$ pwd
/home/terdon/pepe_cant_see/no_restrictions

You must log in to answer this question.

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