The find command

Is certainly one of the most important commands in unix/linux .
For me the most powerful command of the universe (sorry He man! ).

find

1. basic useTypically we use find to find the name of a file in the directory, not just where we left off , but the name of that file exactly .

 

 

In the example below we look jpg ‘s and copy them in our currently directory

find "/tmp/" -type f -name "*.jpg" -exec cp {} . \;

find

 

2. Search by sizeSometimes it is important to find files by their size , and it is sufficient to apply a parameter :

With this command you can find files over 1MB or more. Below e.g

find /bin -type f -size +1000 -exec ls -lnhsrt --color {} \;

find

With this command you can too find files over 10MB or more

find /bin -type f -size +10000 -exec ls -lnhsrt --color {} \;

find

3. Search for user We can also find files that belong to certain user … or does not belong to anyone and have been ” orphaned ” , with the command:

find -nouser

We can also find files that do not belong to a specific user :

find -not -user www-data

4. Search by groupThe same could be applied to search for groups that may affect the group name or GID of the group (with the same flag , care ) , and we would do a simple

find -group GroupName

5. Search permitsOne of the most important uses of find and probably the most complete strangers is its ability to find files with certain permissions , which allows us to detect files that do not have the permissions they should have and that may pose a threat to safety system. The simplest options are -readable use , -writeable and -executable , but we can also use the parameter -perm from which we can establish these three leases simultaneously with the typical combination of three numbers. For example :

find -type f -perm -110

Look for files with executable bit on for the user and group , and the ” – ” indicates that ignores other bits. In other words , it does not matter whether the file is read or write , because we want to display all who have that bit of performance .If we want specific files with executable bit for user and group we would use “/” are sought , and no “- ” :

find -type f -perm /110

What we seek only those files with those permissions , and not others.

more information find

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>