Showing results for 
Search instead for 
Did you mean: 

chmod command


chmod command

Hi everybody
How can I change file mode access permissions to directory with files and subdirectories in it using one chmod command. For instance I have directory named level1 with files in it, also level1 directory has level2 subdirectory in it and so on. I want to chmod to everything in level1 directory to 777 using one chmod command.
Trusted Contributor

Re: chmod command

Of course you can, just assign -R parameter. Thus it can recursively change the file modes bit. For example:
#chmod -R 777 /level1

-Live as you wish-
Gerald Zhou
Chris Wilshaw
Honored Contributor

Re: chmod command

You can also use find to do this with a bit more control

find /level1 -exec chmod 777 {} \;

will change permissions on all files/directories below.

find /level1 -type f -exec chmod 777 {} \;

will change permissions on the files only.

find /level1 -type d -exec chmod 777 {} \;

will change permissions on directories only.
A. Clay Stephenson
Acclaimed Contributor

Re: chmod command

I suggest that you use the find command; it's much safer and will only change the direory permissions -type d.

Now having said this, setting permissions to 777 is very insecure. Don't be tempted to trade convenience for security. I would at least restrict to 775 unless this truly is a wide-open directory.
If it ain't broke, I can fix that.