LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-17-2003, 08:14 AM   #1
brandog
LQ Newbie
 
Registered: Mar 2003
Location: Winnipeg
Distribution: RedHat 8.0
Posts: 28

Rep: Reputation: 15
Chmod Help (is there an easier way?)


Hello, I recently uploaded 3000 photos to my server running apache 2.0 and linux redhat 8.0. Is there a way to change the permissions value all in one shot so it's readible for group and user (744)! I have done 800 by manualy and I Think this is a question worth asking!
 
Old 03-17-2003, 08:54 AM   #2
snocked
Member
 
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Rep: Reputation: 30
chmod -R 744 dir

-R recursively changes permissions of directories and their contents. If you need the dir permissions to differ from its contents, you can just always do a chmod on the dir (without -R) after you do the chmod -R.

Last edited by snocked; 03-17-2003 at 08:57 AM.
 
Old 03-17-2003, 09:16 AM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Or maybe a safer way would be to only change the files which match a certain criteria:

find /my_pics -type f -name \*.jpg | xargs chmod 744
 
Old 03-17-2003, 10:32 AM   #4
doublefailure
Member
 
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747

Rep: Reputation: 30
mik can you explain what xargs does just little bit?
i never could understand what it does reading man page

 
Old 03-17-2003, 05:14 PM   #5
brandog
LQ Newbie
 
Registered: Mar 2003
Location: Winnipeg
Distribution: RedHat 8.0
Posts: 28

Original Poster
Rep: Reputation: 15
Quote:
chmod -R 744 dir
This worked perfectly! You saved me about 10 hours of extra work! Thank you! If anybody new to this cant figur it out; Make sure you supply the full path to the directory!
 
Old 03-17-2003, 06:01 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Quoting doublefailure
can you explain what xargs does just little bit?
I'm not mik, but maybe that'll do :}

Well, it takes whatever you feed it (usually from
stdin, usually something that will result in a number
of arguments >1 ;} ) and passes that as a parameter
to a command...

Lets say you want to display the contents of all
*.txt files in your ~ directory(and subs)....
Code:
find -iname \*.txt | xargs cat
Cheers,
Tink
 
Old 03-18-2003, 03:39 AM   #7
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well the main feature I like about xargs is that it makes sure the command lines don't get to long, when you have a large list of arguments. Which makes it safe to use in scripts.

Ex.

Say you have a directory with thousands of files and you want to do an operation on each file.
chmod 777 *
Would give you the argument list too long error. An easy alternative is:
ls | xargs chmod 777
xargs will not append all the files as parameters but will call the chmod command several times each time with a new batch of files. This will result in something like:
chmod 777 file1 ...... filen1
chmod 777 filen1 ...... filen2
etc...

Uhmm well I don't know if that's any clearer then the man pages, but I hope it at least explains it a bit. You can always stick to Tinksters explanation if mine doens't make sense.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there anything easier than YaST2 gus2 SUSE / openSUSE 16 09-30-2005 05:41 PM
What can we do if we type chmod ugo-x /bin/chmod ?????? bunny123 Linux - Software 3 02-01-2005 08:53 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
Which would be easier? Download-This Linux - Networking 1 10-11-2002 10:59 PM
Windows easier??? Copenhagen Cowboy Linux - Newbie 1 03-09-2001 04:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:34 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