View another user's files in OS X
Is there a way to (temporarily) view another user's file on OS X other than to change the permissions of the file? I'd like the OS to ask for the user name/password.
I guess what I'm looking for is something like Window's idea of running Windows Explorer as another user (ideally at file/directory level only). The ssh idea fails because the Finder cannot recognize the permission granted.
An absolute requirement is not to move the user's files.
Solution 1:
To view the file in Finder (GUI)
NOTE: You're not viewing as the other user - but you're still viewing. Admin rights are required, and the other user's password is not.
This was tested on Mac OS X 10.10 and 10.11 (see below)
- Right-click on the folder you want to see (In Finder)
- Click
Get Info
in the drop-down list that occurs - Click the lock in the bottom-right corner
- Authenticate
- Under
Sharing and Permissions
click+
- Add your own username (or a group, like
Administrators
) with Read (or Read/Write) permissions - Click the lock to prevent further changes
- You're done! You should be able to view the folder in Finder.
Edit for OSX El Capitan and later (10.11)
Although this method still works, the change to El Capitan introduces a default of "rootless" mode. (actually, the real name is System Integrity Protection; SIP) There are certain files that cannot be accessed modified by any user, anyway in this mode. SIP can be disabled if you need to modify these files, (not just view them) and how to do that is outlined here. (If you only need to see them, you shouldn't have to disable SIP)
To view as another user in Terminal
https://unix.stackexchange.com/questions/3568/how-to-switch-between-users-on-one-terminal
Note: This requires you to either have admin rights or the other user password. It only works from the terminal, while the session is active.
- Type
su - otherusername
into the terminal. Replaceotherusername
with the other user's name. If you have admin rights, you can typesudo su - otherusername
to use your password instead of the other user's. You are now logged into the terminal as them. If you just want to log in as root with full access, typesudo su
, and enter your (admin) password. - Change directory to the directory that you'd like to view (/edit).
cd /Users/UserDirectory/subdirectory
- You can now view the files
Solution 2:
EDITED to match edited requirements.
You can achieve exactly what you want by creating a Shared folder. To do so go to System Preferences > Sharing > File Sharing and Add all the folders you want to share.
You can do this, too, by directly selecting a folder in the Finder,, choosing Get Info from the File menu, and enable Shared Folder to share it (or deselect "Shared Folder" to stop sharing the folder).
Extracted from Apple's 101: File Sharing.
You can achieve this in a couple of ways.
Logging as root will grant you read and write privileges to all areas of the file system. You'll need to have the root user enabled. To do so, assuming you're using Lion:
- Go to System Prefereces > Accounts.
- Click the lock and authenticate with an administrator account.
- Click Login Options.
- Click the Edit or Join button at the bottom right.
- Open Directory Utility.
- Authenticate with an administration account.
- Choose Enable Root User from the Edit menu.
- Enter the root password.
Here is described for earlier OS.
Placing the file under the Shared Folder (/Users/Shared), or Sharing the folder, the one where the file you want to edit is, will grant other users access to that file. More about it, and how to Share other folders here.