0

Is it possible to restrict a user from seeing hierarchy of files?

The user shouldn't be able to see the hierarchy of files with ls or any other commands.

  • Why not? All regular users must have permission in their userspace. Typically they can also list the system's root folder and everything else under it except other users' userspace. Now, unless they have sudo privileges they won't be able to mess with anything not in their userspace. What is the problem you're trying to solve? – ChanganAuto Jan 12 '22 at 10:03
  • @KamilMaciorowski As I mentioned in the question, the user shouldn't be able to see the hierarchy of files in any ways. Sorry. I thought it is clear. – Mohammad Jafari Jan 12 '22 at 10:07
  • [Do I really need recursive `chmod` to restrict access to a folder?](https://superuser.com/a/1425631/432690) – Kamil Maciorowski Jan 12 '22 at 10:08
  • 1
    @MohammadJafari: Then you want to restrict the access _to the hierarchy itself,_ not to individual commands. If you focus on restricting `ls`, they'll just use any of the 50 other commands that still allow them to see the same thing. – u1686_grawity Jan 12 '22 at 13:53

1 Answers1

0

If you don’t want other users to see the content of a directory, you can suppress the read right on it (chmod o-r directory. You may need to do it on all the hierarchy (find directory -type d|xargs chmod o-r)

Note that suppressing the read right doesn’t prevent the user to enter it and read its files if the user knows the file names. Only the execution right on the directory (and the read right on the file) is needed for that.

Frédéric Loyer
  • 1,080
  • 3
  • 7