Page 1 of 1

Finding any file anywhere

Posted: 04 Oct 2014, 15:19
by viking60
To quickly find any file anywhere on your Linux system locate will do the job. I like to search for patterns and when I trace those spying Super cookies; finding extensions with *.sol will reveal them.
So this is what I did:

Code: Select all

locate "*.sol"

And sure enough it revealed all the places those rascals were hiding:

Code: Select all

/home/viking/.config/chromium/Default/Pepper Data/Shockwave Flash/WritableRoot/#SharedObjects/869W26XX/macromedia.com/support/flashplayer/sys/settings.sol
/home/viking/.config/chromium/Default/Pepper Data/Shockwave Flash/WritableRoot/#SharedObjects/869W26XX/macromedia.com/support/flashplayer/sys/#www.flashgames247.com/settings.sol
/home/viking/.config/chromium/Default/Pepper Data/Shockwave Flash/WritableRoot/#SharedObjects/869W26XX/www.flashgames247.com/games/sushi-cat-2.swf/Sushi-Cat-2.sol
/home/viking/.tor-browser-en/INSTALL/.macromedia/Flash_Player/macromedia.com/support/flashplayer/sys/settings.sol


The standard flash player setting has a settings.sol so that is "normal" but sushi-cat-2.swf/Sushi-Cat-2.sol is put there by a flash game.

So I made myself an alias to remove all of them and checked again

Code: Select all

locate "*.sol"

- and they were gone.

Then I used flash again and those files and directories were generated again and filled with *.sol files...but this time

Code: Select all

locate "*.sol" 
did not show them!

So can this command not be trusted to find any file on your system?

Yes it can! But it needs a database to make that quick search so when you change stuff on the fly like this - you need to update the database.

Code: Select all

su
updatedb


After that locate will find anything again....
...or you can use

Code: Select all

find -name "*.sol"

(which is way slower than locate but more precise)

Re: Finding any file anywhere with "find"

Posted: 13 Jun 2015, 13:04
by viking60
Find is a very powerful tool that has a lot of flexibility - that means more complexity too.

To find a all files named *.png on your system you would enter this command:

Code: Select all

find -name / "*.png"

To find all png files in /etc you would enter this:

Code: Select all

find /etc -name "*.png"

If you do not enter a location it will start the search from the directory you are in; usually ~/
(remember to use sudo or be root if you are not searching your Home directory)

To combine the search to find both *.png and *.jpg files; you can do something like this:

Code: Select all

find  -name "*.png" -or -name "*.jpg"

(You do not need to write the full word "-or" a simple "-o" will do :-D )

Now let us say you want to only find Directories then you can add "-type" to the equation:

Code: Select all

find -name "Downloads" -type d

The types are d for Directory f for files and l for Links.

So if you use a multinational computer you might want to check several names for the Download directory:

Code: Select all

find  -name "Nedlastinger" -or -name "Downloads" -type d

Mostly I wonder where I saved that #! :f file that I cannot find again so the type f is much used here:

Code: Select all

find  -name "Document.*" -or -name "document-*" -type f

This will find anything named document or Document with any extension so document icons for your theme etc will also be shown.

Find has a lot more to offer than this - here is a practical example:

We all know that those flash cookies violate your privacy because they will not respect the cookie settings in your browser.
To remove all of those supercookies in your home you can use find to locate them and delete them:

Code: Select all

find ~/ -name "*.sol" -delete

Now they are all gone :jackpot

Re: Finding any file anywhere

Posted: 09 Sep 2015, 23:14
by dedanna1029
I used to use locate a lot - I think I will again. It really is very powerful, and flexible.