LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
LinkBack Search this Thread
Old 10-21-2005, 12:51 AM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: Chicago
Distribution: CentOS
Posts: 1,249

Rep: Reputation: 53
Will this command work? chmod -R 644 *.php


Will this command work? chmod -R 644 *.php

I am trying to change all php files to 644 in the directory I am in now and all directories under it.
 
Old 10-21-2005, 01:08 AM   #2
Boby
Member
 
Registered: Feb 2004
Location: Sighisoara/Cluj-Napoca (Romania)
Distribution: CentOS 4, Fedora Core 6
Posts: 781

Rep: Reputation: 31
Hello abefrorman!

Quote:
Will this command work? chmod -R 644 *.php
Yes, this command will work, but will change only all ".php" files in that directory recursively. To chmod all files and all subdirectory of an directory you have to do "chmod -R 664 firstdirectory" and it'll change everything in it.

Hope this helped, Boby!
 
Old 10-21-2005, 01:20 AM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
If the goal is to change only files that end with ".php" in the current directory and all subdirectories, then you'll need something else.

As Boby mentioned, the original command "chmod -R 644 *.php" will only chmod files in the current directory that end with ".php"

Boby's command will recursively chmod any file beneath the specified directory (no matter what extension the file has).

The find command is probably the right tool for the job:
Code:
find /top/level/directory -type f -name "*.php" -exec chmod 644 {} \;
That will find every regular file that ends with ".php" in the /top/level/directory and all subdirectories and it will execute "chmod 644 <found filename>" for each one.

Last edited by Dark_Helmet; 10-21-2005 at 01:22 AM.
 
Old 10-22-2005, 08:26 AM   #4
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Code:
find /top/level/directory -type f -name "*.php" -print | xargs chmod 644
is more efficient, though, as it doesn't result in spawning a new chmod(1) process for each file found.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CHMOD Command dudeman41465 Linux - Software 1 09-26-2005 02:29 AM
chmod 644 /etc/shadow stomach Linux - General 15 09-12-2005 08:28 PM
chmod command linuxtesting2 Linux - Newbie 2 09-03-2004 12:02 PM
Apache and php + chmod 644 daveo Linux - General 2 10-10-2003 08:33 AM
Chmod command gogo Linux - General 2 09-24-2002 07:01 AM


All times are GMT -5. The time now is 11:34 PM.

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