Delete all files on a server with a particular filename
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Delete all files on a server with a particular filename
Dear All,
I wonder if you could help me please. I run 5GBFree.com a free hosting site. As you can imagine, it gets quite a few people signing up to abuse the service.
Recently I've found a LOT of people setting up sites with a particular script that floods forums and IRC chat rooms. The names of the files are as follows:
Is there a command I can run to remove files with these filenames ANYWHERE on the server (so basically, a command to go through all folders on the server and remove instances of that name).
If you could help I would really appreciate it, and I'm sure the people who run the forums and IRC rooms getting spammed would also be grateful to you.
Are you looking to run a cron job to execute at specific intervals? Sounds more feasible to me so you don't use all of your resources just to scan your system. And you could use the find command to do the job.
Thanks Josh. Ideally yes, a cron job would be fantastic but I'm no where near at the level I need to be at to set one up so I guess I'll just have to perform the job manually.
I ran the command above and got the following result:
I'm afraid I'm a REAL linux n00b! I typed 'man find' at the command prompt and LOTS of text appeared far too fast for me to read it!
I know I'm being cheeky but if you knew the command I need exactly I'd be really appreciative.
Kind regards,
Rob
Hi,
You're welcome, no problem at all. Normally if you just type the command man find, you get the man page for that command presented and you can scroll through the document using the arrows, page up and down or search for a string by typing / followed by the string you want.
There's no shame at all in being a newbie, we all have to start somewhere and believe me nobody holds all the knowledge.
My buddy corp769 already provided an example but...
using the . means the find command will start looking at the directory you're in when executing the command. So either you change directory (cd) to where you want to run the search or you provide the path where to search instead of the . (dot).
Note that the example I provided is scanning the directory you are currently in, you need to tell it where to scan from. And as far as setting up a cron job, read here: http://www.cyberciti.biz/faq/how-do-...-or-unix-oses/
I've manually checked a few spammers sites and the files are still there, dammit!
Cheers,
Rob
Hi,
Execute the command without the -exec part to see if any files are found. What's the path where those files normally get created? Do you have permissions as your user to that path and files?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.