In Linux/Unix, if I am inside a directory of another user, but cannot view the contents of the directory by typing "ls," how do I get a copy of all the files?
Is the only way to guess what the file names are?


In Linux/Unix, a directory is itself a kind of file that can only be modified by special system calls. Like any other file, access to it is controlled by file permissions.

Looking at it in terms of actually implementation, your question boils down to "how do I read a directory file I can't read?" I'm not making fun of your question — I'm just trying to explain why the answer is a definitive "no".

  • I suppose it's indeed silly, but it's nice to know for sure! thanks – Trevor Hickey Nov 27 '12 at 5:07
  • The way you asked the question is not silly. The way I rephrased your question makes it look silly, but I did that to make the logic clear. – Isaac Rabinovitch Nov 27 '12 at 8:11

You need to have super-user priviledges (a.k.a sudo) to do that.

sudo ls /home/Peter/

(if you want to view Peter's files)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.