I would like to change permissions of a folder and all its sub folders and files in one step (command) in Linux.
I have already tried the below command but it works
Check the -R option
chmod -R <permissionsettings> <dirname>
In the future, you can save a lot of time by checking the man page first:
man <command name>
So in this case:
man chmod
You can use -R
with chmod
for recursive traversal of all files and subfolders.
You might need sudo as it depends on LAMP being installed by the current user or another one:
sudo chmod -R 755 /opt/lampp/htdocs
You want to make sure that appropriate files and directories are chmod-ed/permissions for those are appropriate. For all directories you want
find /opt/lampp/htdocs -type d -exec chmod 711 {} \;
And for all the images, JavaScript, CSS, HTML...well, you shouldn't execute them. So use
chmod 644 img/* js/* html/*
But for all the logic code (for instance PHP code), you should set permissions such that the user can't see that code:
chmod 600 file
You can change permission by using following commands
sudo chmod go=rwx /opt/lampp/htdocs
For Mac OS X 10.7 (Lion), it is:
chmod -R 755 /directory
And yes, as all other say, be careful when doing this.
chmod -R 755 directory_name
works, but how would you keep new files to 755 also? The file's permissions becomes the default permission.