LINUX - Delete Weird File

I have two ways to delete WEIRD files

For some reason I see alot of questionable files (literally thier names are like "?? ??" sometimes they have wierd heartograms and upside down pentagons... who knows.. bad encoding or something)

Any how to delete them Try the following 3 steps



1. DELETE WITH REGULAR DELETE

ls -lisah
rm -rf "?? ??"



2. DELETE WITH INODE 

ls -lisah

Note the inode number of the file - its the unique identifier of the file on that file system
Note the inode number is the number on the left most column

First run this to make sure it finds the file we want to delete (Note replace INUM with the actual integer value representing the inode #):
find . -inum INUM

find . -inum INUM -exec rm -i {} \;
Type yes and hit ENTER when it prompts to delete the file - and then if it continues to do its search for further files - just cancel out of the search by pressing CTRL-C



3. INSTALL MIDNIGHT COMMANDER (MC) 

MC is the like the old Norton Commander from DOS to all those familiar with it

apt-get update

apt-get install mc

mc

Scroll to the files with the ARROW KEYS and the ENTER key to enter

Use the INSERT key to select more or less Files

Hit F8 to delete the file 

Hit F10 to exit mc (typing "exit" will exit as well)

NOTE1
ENABLING HIGHER FUNCTION KEYS IN PUTTY: Sometimes Putty doesnt let you use the higher Functions keys (F5 to F12 I believe) to enable them so that you can delete (F8) and exit (F10). When setting up the Shells session (you can even change this mid session by going to Change Settings) follow the tree to the Terminal then Keyboard Menu and Check "Xterm R6" (the default is "ESC|n~" which we dont want ). 

NOTE2
If following the Note above to Enable function keys - another crucial settings I always set as a default template for all of my putty sessions is to have a HUGE scrollback so I can scroll back through my steps and recall my inputs and command outputs- Follow the tree of the Putty Settings to Window and Set the Lines of Scrollback from 200 to 2000000, Just literally append a few zeroes to the end of it and call it good.




Comments