Marcin Kliński
Marcin Kliński

Reputation: 13

Bash SSH change CHMOD in all files with a specific name?

I have multiple Joomla! sites. How to search and change CHMOD in all "configuration.php" files with bash SSH to 444 ?

Upvotes: 0

Views: 261

Answers (3)

Simon PA
Simon PA

Reputation: 746

You can try:

find / -name "configuration.php" -exec chmod 444 {} \;

(I haven't tested the syntax.)

Upvotes: 0

selalerer
selalerer

Reputation: 3924

Something along the lines:

SERVERS="server1.example.com server2.example.com server3.example.com"

COMMAND_TO_RUN="find . -name configuration.php | xargs chmod 700"

for SERVER in "$SERVERS"
do
    ssh SERVER <<EOF
    "$COMMNAD_TO_RUN"
    EOF
done

Upvotes: 2

neuhaus
neuhaus

Reputation: 4094

Use this:

find /path -type f -name configuration.php -exec chmod 444 {} \;

You can also pass more than one path to find: find /path1 /path2 ...

Upvotes: 1

Related Questions