Terminal cmd for recursive perm fix?
apple Verified ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I need to issue a Terminal command to tidy up all files' & directories' rights and permissions in a specific path. Anyone care to remind me, please? The dir in question is ~/Desktop/dir and I need to make everything Read & Write for me, others None. Using the Inspector, I would have to go to each and every sub-dir and click many times with the mouse. Not for me.
Many thanks, as always.
15 replies
Sign in or join Beachball Help to reply.
- 0
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Alternatively you can get info (or use the inspector) on the parent folder, change permissions down at the bottom, and then use the gear menu to apply permissions to the enclosed items.
Message was edited by: Topher Kessler
- 0
Niel ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
The exact command needed is:
chmod -R 700 ~/Desktop/dir
(33198)
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
oops
Message was edited by: Topher Kessler
- 0
V.K. ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Be VERY careful with the "apply to enclosed items" button that Topher mentioned and never use it on system created folders like the desktop folder itself. theose folders sometimes have invisible ACLs ( ~/Desktop has one) and using that button will prpagate those ACLs to everything inside. also, I'm not sure why you want to change those permissions anyway. You desktop folder is only readable by you and therefore nobody but you can see anything in ~/Desktop/dir anyway.
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
For home directory contents in a single-user environment this shouldnt be a problem, but any of these commands should be used with the same level of caution, as propagating permissions down a directory tree can have adverse effects if the system or other processes depend on them.
- 0
Alex Zachopoulos ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Right, guys, thanks very much for the (very fast) feedback; I feel I need to clarify my situation a bit:
A colleague at work dumped some files for me over wLan into a folder that I share for office use. To do that, because they basically are on WInXP at the office, I've setup this dummy user account on my Mac, named it LAN (predictably), gave "" as its password (so they don't have to enter anything) and created on its ~/Desktop/ the Shared dir, i.e.
~/Desktop/Shared (inside the LAN account, that is).
I then proceeded to make a shortcut for it on MY desktop, i.e.:
~/Desktop/ (inside the ALEX account, that is)
after fiddling with the rights for it, so that I can access it without actually switching user accounts.
Back to the file transfer from the colleague. The files arrived, but some of them are set to None for other users, and they therefore are blocked off to me. I have to change that.
To facilitate the change, I moved the dir that the colleague dumped into my 'Shared' dir, and placed it on my Desktop. I can easily move it elsewhere, if that alleviates the concern about ACLs (BTW, what
are ACLs?)Hope you can now give more specific and sure instructions. Thanks very much!
- 0
Alex Zachopoulos ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
BTW, I've already solved the situation, by making a new folder on my desktop, placing the problematic one inside that one, then propagating from there only,
not from the Desktop.I would like to understand a bit more about the concerns expressed in your replies, though. And thanks for the Propagate... tip! Very handy, GUI-sort of tip!
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
ACLs are access control lists, which are extended permissions properties for files which are better suited for elaborate multi-user environments. They not only allow properties, but also deny them and have many more nuance variations to permissions beyond "read", "write", "execute", and "none".
The standard permissions are called "Posix" permissions, and are quite dated and a bit limited.
Message was edited by: Topher Kessler
- 0
Niel ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Use the following command:
sudo chown -R $UID ~/Desktop/dir
This command will ask you for your administrator password, which won't produce anything in the Terminal window. Alternatively, you can duplicate or copy the folder in the Finder and click Authenticate if prompted followed by entering the password.
(33199)
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Many system processes rely on the user and group to be set to specific things. For instance, if you're running a quicktime streaming server on a computer, you will need to have a special user called "_qtss" that owns the directory the media files are in. If you change the owner to something else then your media will no longer stream.
This type of thing is true for most of the files in your /System and /Library folders (the ones at the root of the drive) as well as for the many hidden files on your computer as well.
- 0
Alex Zachopoulos ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
To Niel:
What's the difference between the two commands you recommended?
sudo chown -R $UID ~/Desktop/dir
chmod -R 700 ~/Desktop/dirI know 'chown' is for 'Change Ownership'. What's chmod? And why do you suggest both?
Thanks.
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
the chown command is a "change ownership" command, and the chmod command is a "change mode" (or permissions) for a file.
The $UID variable is your user id number. To see what it is, type "echo $UID" in the command line.
The chown command that Neil posted will change the owner of all the files in the directory to yourself (or
ensure they are all owned by you), and the chmod command will then modify the permissions accordingly (as we discussed above).the "sudo" command put before other commands runs them as "root", which is needed to change the ownership and permissions of some files, especially those that do not belong to you. Adding it before the command ensures the command will run without any "access denied" errors. After the owner has been changed to yourself, then the chmod command can be run without "sudo" before it, as the file(s) already belong to you so you have complete control.
Message was edited by: Topher Kessler
- 0
Alex Zachopoulos ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Ah, makes sense. And the '700' is code for ....what?
- 0
Topher Kessler ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
The 700 is a bitwise notation for user, group, and everyone else's permissions.
It's basically: chown
abc filename, where:a=user permissions
b=group permissions
c=everyone elseThe specific number is:
0=none
1=execute
2=write
4=readTherefore, if you want read and write permissions for the owner, and "none" for everyone else, then you'd add the numbers for "read" and "write":
read=4
write=2
read+write=6Therefore, the command is: chmod 600 filename
In Neil's command he put "700", which gives the owner "execute" permissions as well as read and write. These are just added permissions for running scripts or programs that may be in the targeted folder.
Using bitwise operators like this targets the whole Posix permissions set (all entries: user, group, others) at one time. To change the permissions for only one option, you'd do something like this:
chmod u=rw filename
This will only modify the user (owner) and give him read and write permissions on the file.
To get a complete list of what can be done, check out "chmod" on wikipedia or the man pages in your terminal (type "man chmod" in the terminal to get the man pages).