I am an admin that wants to access other users' files. How to do this via the Terminal?
2 Answers
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
.
-
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
-
1Once you become
bob
withsudo su - bob
you no longer need to prefix each command withsudo
. You arebob
at that point and can see anythingbob
is allowed to see. To move files to your account it's best to do it withsudo
. Like:sudo cp -r ~bob/Documents/Some\ Folder ~/Documents/
to copySome Folder
inbob
's documents to yourDocuments
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. Apr 2, 2020 at 0:43
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.
-
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.– douggroJan 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