Issue
I am seeking a terminal command to recursively go through folder structures and either delete .htaccess
files with permission of 0444 and/or if possible to match the first line in the file for a safety measure.
Had a few accounts compromised on a server, which cleared up the malware / rootkits but noticed it added .htaccess
files inside every folder with the following content:
<FilesMatch ".(py|exe|phtml|php|PhP|php5|suspected)$">
Order Allow,Deny
Deny from all
</FilesMatch>
Solution
You can use find
to go recursively through multiple directories, search for files and execute a command like rm
on the result.
find . -type f -perm 0444 -name ".htaccess" -exec echo rm {} \;
.
current diretory / can be other path e.g./etc
-type f
search for files-perm 0444
permission 0444-name ".htaccess"
will only look for files named.htaccess
-exec CMD {} \;
run command likerm
on the result{}
- verify output of
find
and removeecho
to remove files
Answered By - dnltinney