Pages

Monday, September 10, 2007

How to Find Files and Folders in Linux Using the Command Line


Using the Find Command

The “find” command allows you to hunt for files for which you know the round filenames. The simplest form of the command probe for thread in the stream instructing and recursively through its subdirectories that pair the supplied try criteria. You can search for list by name, holder, group, type, permissions, date, and other criteria.

Find specific file name
#find {location}  -name {filename }

Example
[root@srtrwold01 ~]# find /home -name rman.txt
/home/rman.txt
/home/oracle/rman.txt

Find all files like name like
#find {location}  -name {filename\*}
  
Example

[root@srtrwold01 ~]# find /production/user1/  -name openssl\*
/production/user1/user1/openssl
/production/user1/user1/openssl/openssl-devel-0.9.8e-27.el5_10.3.x86_64.rpm
/production/user1/user1/openssl/openssl-0.9.8e-27.el5_10.3.x86_64.rpm
/production/user1/openssl
/production/user1/openssl/openssl-devel-0.9.8e-27.el5_10.3.x86_64.rpm
/production/user1/openssl/openssl-0.9.8e-27.el5_10.3.x86_64.rpm
[root@srtrwold01 ~]#


The “find” command allows you to search for files for which you know the approximate filenames. The simplest form of the command searches for files in the current directory and recursively through its subdirectories that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria.
find . -name pro\*

Using the Which Command 

The “which” command returns the absolute path of the executable that is called when a command is issued. This is useful in finding the location of an executable for creating a shortcut to the program on the desktop, on a panel, or other place in the desktop manager. For example, typing the command “which firefox” (without the quotes) displays the results shown in the image below.
#which -a {program name}

Example
[root@srtrwold01 ~]# which -a firefox
/usr/bin/firefox
[root@srtrwold01 ~]#

Using the Whereis Command

The whereis command is used to find out where the binary, source, and man page files for a command are located. For example, typing “whereis firefox” (without the quotes) at the prompt displays results as shown in the following image

# whereis {program name}

Example
[root@srtrwold01 ~]# whereis cups
cups: /etc/cups /usr/lib/cups /usr/share/cups

[root@srtrwold01 ~]# whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /usr/share/man/man1/firefox.1.gz

No comments:

Post a Comment