3

I am an admin that wants to access other users' files. How to do this via the Terminal?

0

2 Answers 2

3

As stated by patrix: the personal files of other user's on the same machine are generally stored in the /Users/<username> folder for each user. The permissions on these folders are usually set such that they are private to the individual who owns the files.

This means you need to use sudo to elevate your own access levels in order to see their files. If you are truly an admin, using sudo is something that's ok, but do so with caution. If you are not an admin then you shouldn't have the proper sudo privileges to do any of this and your repeated attempts to use sudo are logged in the system access log.

To simply list files in another user's home directory (let's call them bob) you do:

sudo ls ~bob

The ~ prefix is POSIX shorthand for "home directory of...". To browse freely, you can become that user with sudo like so:

sudo su - bob

This makes you bob, logged in as bob and in bob's home directory. You can now move around, cat files, open files, etc. as bob.

3
  • When I become Bob, do I have to write su for each command? Can I move files to my account? Jan 3, 2015 at 22:18
  • 1
    Once you become bob with sudo su - bob you no longer need to prefix each command with sudo. You are bob at that point and can see anything bob is allowed to see. To move files to your account it's best to do it with sudo. Like: sudo cp -r ~bob/Documents/Some\ Folder ~/Documents/ to copy Some Folder in bob's documents to your Documents folder.
    – Ian C.
    Jan 3, 2015 at 22:38
  • actually the permission of the home folders are usually set to be readable by everyone. MacOS doesn't do a good job at protecting privacy.
    – qwertzguy
    Apr 2, 2020 at 0:43
1

The home folders of all users are stored in /Users. Assuming you have the technical and legal rights to access files of other users, you can do this by changing into their home folder (cd /Users/joe or cd ~joe) and accessing the files there.

4
  • Strangely enough I cannot access the files even though I am admin on the computer. Jan 3, 2015 at 14:28
  • Then you don't have the technical rights to do so (check folder permissions to verify).
    – nohillside
    Jan 3, 2015 at 14:35
  • 1
    @LoveLearning Even admin users do not have access rights to other users folders in Terminal. You can invoke sudo privileges to access them provided, as patrix said, you have technical and legal rights to do so.
    – douggro
    Jan 3, 2015 at 14:50
  • Yes I have all rights. I was just too lazy to log out and then in again to the other user where I had saved a PDF file. Jan 3, 2015 at 22:15

You must log in to answer this question.

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