Results 1 to 7 of 7
Hi
I'm new to linux and linux command. I have sites that been hacked and need to overwrite some files that been modified by hacker.
How can I find files ...
- 12-16-2009 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 3
Find and Repace File
Hi
I'm new to linux and linux command. I have sites that been hacked and need to overwrite some files that been modified by hacker.
How can I find files "index.php" in a subfolders of \home and replace with 'index.php' file in the root ? Much appreciate.
Thank you.
Loh
- 12-16-2009 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
use the find command. check the man page for more
Code:find /home/ -type d -exec cp "/root/index.html" "{}" \;
- 12-16-2009 #3Just Joined!
- Join Date
- Dec 2009
- Posts
- 3
Will this command overwrite all index.html files in the /home subfolders?
"/root/index.html" copy to "/home/sub1/index.html"
"/root/index.html" copy to "/home/sub1/sub2/index.html"
- 12-16-2009 #4Linux Newbie
- Join Date
- Dec 2009
- Posts
- 103
Hi,
For locating giles I use "locate". Run "updatedb" first, that will update your database of files, then use locate as follows:
"locate filename"
That will give you a list of all files in the entire file system with a matching name.
Dave
- 12-16-2009 #5Just Joined!
- Join Date
- Dec 2009
- Posts
- 3
After reading some tutorial, I think this should work.
What I'm trying to do is copy index file from source to subfolders to overwrite the existing files.
"/home/source/index.html" copy to "/home/sub1/index.html"
"/home/source/index.html" copy to "/home/sub1/sub2/index.html"
Do I miss anything?
Code:find /home/dest -type f -name "index.html" -exec cp /home/source/index.html {} \;
- 12-16-2009 #6Linux Newbie
- Join Date
- Dec 2009
- Posts
- 103
Hi,
I'm not qualified to check that, sorry... I would use "cp "source" "destination". That should overwrite. Be sure to make a backup of the original files you want to save... I am as new at this as you are...
Dave
- 12-16-2009 #7Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
Look right to me. The thing that I sometimes do to verify I have it right is run it with 'echo' before the command so you can see what will be executed when you actually do run it.
Code:find /home/dest -type f -name "index.html" -exec echo cp /home/source/index.html {} \;


Reply With Quote
