Tuesday, September 08, 2009

Using Find Command | Ubuntu Howto

Tech Blog - Here is a quick how to using the find command in Unix, Ubuntu and other Linux distribution operating system, the find command is a very useful command, find will search any set of directories you specify for files that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria. The search is recursive in that it will search all subdirectories.

Some useful find command used below

Search for file in a specific directory in this case /usr
$ find /usr -name "httpd.conf" -print

Search and execute chown apache:apache on the file httpd.conf when it find it
$ find /usr -name "httpd.conf" -exec chown apache:apache '{}' \;

Look for files more than 50mb under /var folder nad list the files
$ find /var -size +50000000c -exec ls -lt {} \;

Look for files under the directory but do not descend
$ /usr/bin/find / -xdev -size +50000000c -exec ls -lt {} \;

Find and delete core file on your system
$ find / -name core -exec /bin/rm -f '{}' \;

Hope this help.

1 comments:

Anonymous said...

nicely explained but,please mention small details like leave a space between command and parameter also between curly brackets and \;

Looking for a tech tip? By installing a spyware remover your computer will be safe.

Get the latest phones like the HTC HD2 and many more, only at Phones 4U.

Best Web Host lists the best web hosts in today's market.

For suggestion and concerns E-mail