LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 03-23-2011, 07:32 AM   #1
Robbeh
LQ Newbie
 
Registered: Mar 2011
Posts: 16

Rep: Reputation: 0
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:

peindom1.php
peindom2.php
peindom3.php
peindom4.php

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.

Kind regards,
Rob
 
Old 03-23-2011, 07:34 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello and Welcome to LinuxQuestions,

Have a look at the man page of find, more in particular the use of -exec.
Code:
man find
Looking forward to your participation. Have fun with Linux.

Kind regards,

Eric
 
1 members found this post helpful.
Old 03-23-2011, 07:35 AM   #3
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
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.
 
Old 03-23-2011, 07:36 AM   #4
Robbeh
LQ Newbie
 
Registered: Mar 2011
Posts: 16

Original Poster
Rep: Reputation: 0
Thankyou for your welcome, Eric.

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
 
Old 03-23-2011, 07:36 AM   #5
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
You could use something like this:
Code:
find . -type f -name "peindom*" -exec rm -f {} \;
Cheers,

Josh
 
Old 03-23-2011, 07:42 AM   #6
Robbeh
LQ Newbie
 
Registered: Mar 2011
Posts: 16

Original Poster
Rep: Reputation: 0
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:

5gbfree:~# find . -type f -name "peindom*" -exec rm -f {} \;
5gbfree:~#

So I don't know if that's done the job or not (I assume not as it's a find command and not delete?).

Thankyou again,
Rob
 
Old 03-23-2011, 07:42 AM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Robbeh View Post
Thankyou for your welcome, Eric.

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).

Kind regards,

Eric
 
Old 03-23-2011, 07:44 AM   #8
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
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/
 
1 members found this post helpful.
Old 03-23-2011, 07:45 AM   #9
Robbeh
LQ Newbie
 
Registered: Mar 2011
Posts: 16

Original Poster
Rep: Reputation: 0
Thankyou for that. I don't just want to find the files though, I want to remove them?
 
Old 03-23-2011, 07:45 AM   #10
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
And Eric, glad to know I am your buddy LOL
 
Old 03-23-2011, 07:47 AM   #11
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Robbeh View Post
Thankyou for that. I don't just want to find the files though, I want to remove them?
Hi,

That's what the
Code:
 -exec rm -f {} \;
part takes care of. find will pass any file that meets your criteria as parameter to the rm -f command and remove it.

Kind regards,

Eric
 
Old 03-23-2011, 07:47 AM   #12
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by Robbeh View Post
Thankyou for that. I don't just want to find the files though, I want to remove them?
In the example I provided, the exec function of the command executes rm to remove the files found.

Cheers,

Josh
 
Old 03-23-2011, 07:48 AM   #13
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by corp769 View Post
And Eric, glad to know I am your buddy LOL
Hi,

You're welcome dude.

Kind regards,

Eric
 
Old 03-23-2011, 07:49 AM   #14
Robbeh
LQ Newbie
 
Registered: Mar 2011
Posts: 16

Original Poster
Rep: Reputation: 0
Hi Josh,

Thankyou - I'm afraid that command didn't work

I've manually checked a few spammers sites and the files are still there, dammit!

Cheers,
Rob
 
Old 03-23-2011, 07:50 AM   #15
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Robbeh View Post
Hi Josh,

Thankyou - I'm afraid that command didn't work

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?

Kind regards,

Eric
 
  


Reply



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
Need help creating a script to delete part of a filename Scorpuk Linux - Newbie 2 07-28-2008 10:19 AM
Trying to delete a filename with special characters Harry Seldon Linux - General 11 03-20-2007 01:31 PM
How to delete wierd filename from my server? DaveNET Linux - General 3 06-27-2006 01:39 PM
change uploaded files from filename.avi to filename.avi.html like www.rapidshare.de latheesan Linux - Newbie 3 06-16-2005 04:33 AM
Files delete from SAMBA server klmn1 Linux - General 2 04-17-2004 02:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:46 PM.

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