Win Unix Mac

Articles,How Tos,Tips n more

  • Increase font size
  • Default font size
  • Decrease font size

Find things on your Linux system

E-mail Print PDF

Linux command line can be confusing to beginners, the file system layout may be different from the pc you have at home but with a few choice commands you can find the files you are interested in easily.

I will demonstrate a few easy to remember and practicle examples of how to use find on your Linux / Unix platform. Being as these individual files and programs vary from vendor and OS they may not be applicable to all Linux's , but most will be.

There is actually a find command, but most people fail to get the hang of it first time, in the Windows / Mac / Gui web world this is a big problem called usability. In the Unix/Linux world the best and most useful command are usually not that easy to use.

find . -iregex .*something.*


On a RedHat styled or based Linux this would do a case insensitive search for files containing the word something in the filename, starting with the current folder and going recursivley.

Here is a practicle example of a case insensitive search within the /sbin directory :

[root@f11 sbin]# find . -iregex .*oo.*

./ethtool

./pivot_root

./reboot

./mii-tool


The find command can also be used on the rest of the filesystem ( assuming you have rights or permissions to do so ), for example to find and count all the .php files under home you could use this find syntax and expression :

[root@f11 ~]# find /home -iregex .*\.php.* | wc -l

2072

The find command really is very powerful and versatile, it has evolved over tens over years and is one of the most feature packed find programs available today. Below I demonstrated the newer than / older than functions as there use can be interesting for security and monitoring purposes. The example i give below is listing the /tmp directory and then selecting a file.

In this case i chose the Joomla_1.5.14-Stable file:

[root@f11 tmp]# ls -l
total 6560
drwxr-xr-x  2 daemon daemon    4096 2009-10-19 23:41 hsperfdata_daemon
drwxr-xr-x  3 daemon daemon    4096 2009-10-20 20:56 Jetty_0_0_0_0_9090_webapp____-dnguxu
-rw-r--r--  1 root   root   6685772 2009-10-12 18:28 Joomla_1.5.14-Stable-Full_Package.zip
drwx------. 2 neil   neil      4096 2009-09-30 06:53 keyring-U8Xu8o
drwx------. 2 neil   neil      4096 2009-09-30 06:54 pulse-FP55HZU8m5VM
drwx------. 2 gdm    gdm       4096 2009-09-30 06:53 pulse-XaKGcr5v1Zgq
drwxr-xr-x  3 root   root      4096 2009-09-30 06:51 vmware-config0
drwx------  2 root   root      4096 2009-10-13 18:59 vmware-root


Now we do a find on all files newer than the Joomla zip file :

[root@f11 tmp]# find . -newer Joomla_1.5.14-Stable-Full_Package.zip
.
./hsperfdata_daemon
./hsperfdata_daemon/16385
./.ICE-unix
./Jetty_0_0_0_0_9090_webapp____-dnguxu
./Jetty_0_0_0_0_9090_webapp____-dnguxu/jsp
./vmware-root

These examples give only an indication of the usefulness and power of find, be sure to check out the find manual on your Linux/Unix system with the command man find

Last Updated on Wednesday, 21 October 2009 20:24  

Add your comment

Your name:
Subject:
Comment: