LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can I change the directory I am currently in and all directories under it to 755? (https://www.linuxquestions.org/questions/programming-9/how-can-i-change-the-directory-i-am-currently-in-and-all-directories-under-it-to-755-a-375404/)

abefroman 10-21-2005 08:19 AM

How can I change the directory I am currently in and all directories under it to 755?
 
How can I change the directory I am currently in and all directories under it to 755? Currently they are 775

fouldsy 10-21-2005 08:26 AM

chmod -R 0755 /path/to/rootfolder

druuna 10-21-2005 08:26 AM

Hi,

cd ..
chmod -R 755 <directory you where previously in>


If the directories are actually changed from 775 to 755 depends on who's owner of those directories and who's executing the chmod command. root is the only user which does not have this restriction.

man chmod for more details.

Hope this helps.

abefroman 10-21-2005 01:29 PM

Wont that change all directories and files? I am trying to do directories only? (leave the files as 644)

WHat is the difference between
chmod -R 0755 /path/to/rootfolder
and
chmod -R 755 /path/to/rootfolder

lowpro2k3 10-21-2005 01:45 PM

Quote:

Originally posted by abefroman
Wont that change all directories and files? I am trying to do directories only? (leave the files as 644)

WHat is the difference between
chmod -R 0755 /path/to/rootfolder
and
chmod -R 755 /path/to/rootfolder

I wanted to do the same before, see this thread for a few solutions (a recursive script, and a crafty find command).

Make sure you read the whole thread to get the right script. I love the idea of using 'echo chmod permissions file' to echo what will actually happens before running it. You should do this first to simulate that everything will work as expected.

Or just use the find command :p

druuna 10-21-2005 01:46 PM

That's correct, files and dirs are changed.

There's no option in chmod that can do this, you could use find:

find . -type d -exec chmod 755 {} \;

The above will changes dirs only (-type d).

There is no difference between 0755 and 755. The first number (0) is for setting sticky bit(s) and can be ignored for 'normal' modifications. See man chmod for details.

Hope this helps.

jschiwal 10-21-2005 06:15 PM

If this is your home directory that you are talking about, be careful when using chmod on hidden directories such as .kde. Sometimes a subdirectory will have a different group owner that needs write access to function normally. Also, if you have a ~/tmp directory or a tmp directory in .kde or .gnome, these directories might on your system serve a similar function as the main /tmp directory for a number of services which run as a psuedo user.

Suppose that your default user is users. You could restrict find result with the "-group users" predicate. This should make the command safer by restricting the change to directories with your default gname.


All times are GMT -5. The time now is 12:14 AM.