Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: 55
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
Registered: Feb 2004
Posts: 781

Rep: Reputation: Disabled
Hello abefrorman!

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
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
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:
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
Registered: May 2005
Posts: 378

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


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
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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:48 AM.

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