LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-12-2009, 08:42 AM   #1
pratikvimal
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Rep: Reputation: 0
How to change the permissions the whole directory?


Hi,
I am trying to change the permissions of all the files in a particular directory. I have to change their permissions one by one. Is there any wasy such that we can change the permissions of whole directory at once. I mean permissions of all the files at once?

Regards,
Pratik
 
Old 06-12-2009, 08:50 AM   #2
jdkaye
Senior Member
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 4,576

Rep: Reputation: Disabled
You can use wildcards (*, ?) in the chmod command so this
Code:
chmod ugoa+rw *
will make all the files in the folder readable and writeable.
cheers,
jdk
 
Old 06-12-2009, 09:08 AM   #3
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 115

Rep: Reputation: 16
Also you can use the -R flag to change permission in a directory and sub directories recursively,

Quote:
chmod ugoa[+/-]rwx -R [folder]

Last edited by NightHorse; 06-12-2009 at 09:09 AM.
 
Old 06-12-2009, 09:08 AM   #4
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
cd dirname
chmod 777 *

this will change all the files in dirname to -rwxrwxrwx
 
Old 06-12-2009, 09:09 AM   #5
pratikvimal
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Original Poster
Rep: Reputation: 0
What is this *?
 
Old 06-12-2009, 09:10 AM   #6
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
If there are subdirectories, containing files, then you can use the recursion option, which causes the command to enter subdirectory trees as well. (see chmod --help)

It is better to give different permissions to directories than you do for files. Only programs and scripts should have the 'x' bit set. But you want directories to have the 'x' bit set. For directories, the 'x' bit allows you to enter them. You can use the `find' command to find just files or just directories:

find . -type d -exec chmod ug=rwx,o= '{}' \;
find . -type f -exec chmod ug=r,o= '{}' \;

The '{}' characters is a place holder for the file found.
 
Old 06-12-2009, 09:10 AM   #7
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 115

Rep: Reputation: 16
* is special character (wild card) denotes everything is a directory.
 
Old 06-12-2009, 09:12 AM   #8
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 115

Rep: Reputation: 16
* is a wild card (special character denotes everything in a directory)
 
Old 06-12-2009, 09:12 AM   #9
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 3,931

Rep: Reputation: 602Reputation: 602Reputation: 602Reputation: 602Reputation: 602Reputation: 602
um, will 'chmod -R dirname' do it
 
Old 06-12-2009, 09:59 AM   #10
pratikvimal
LQ Newbie
 
Registered: Jun 2009
Posts: 18

Original Poster
Rep: Reputation: 0
@NightHorse
it worked..

thanks
 
Old 06-12-2009, 10:13 AM   #11
NightHorse
Member
 
Registered: Jun 2009
Location: Egypt
Distribution: Ubuntu 10.04
Posts: 115

Rep: Reputation: 16
You are welcome.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Permissions change when I mount a directory AmdMhz Linux - Newbie 2 02-04-2009 03:36 PM
How do I change directory permissions ? cwolf78 Linux - Software 3 05-05-2005 12:15 PM
FTP Change Directory Permissions rubbercash Linux - Networking 5 07-29-2004 04:54 PM
can't change directory permissions walterbyrd Debian 7 07-24-2004 01:20 PM
How do I Change directory permissions? Stevetgn Linux - Newbie 8 06-09-2004 12:09 AM


All times are GMT -5. The time now is 08:27 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration