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.

2 comments:

Anonymous said...

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

sakib said...

A few examples and a little detail would make the post more useful.

For suggestion and concerns E-mail