LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2005, 08:19 AM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
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
 
Old 10-21-2005, 08:26 AM   #2
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
chmod -R 0755 /path/to/rootfolder
 
Old 10-21-2005, 08:26 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 10-21-2005, 01:29 PM   #4
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
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
 
Old 10-21-2005, 01:45 PM   #5
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
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
 
Old 10-21-2005, 01:46 PM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 10-21-2005, 06:15 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 06:54 PM
Remove directory and sub directories newuser455 Linux - Newbie 5 06-01-2005 12:31 AM
1755 to 755 directory L-system Linux - Security 1 01-25-2005 09:40 PM
how to change exisitng files/directory permission from 755 to 770 mweil Linux - Newbie 3 07-01-2004 10:18 AM
chmod 755 won't change file permission. duffboygrim Linux - General 11 04-29-2004 06:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration