
Locate Commands
1. First run updatedb -v (or updatedb) to update database (only superuser can run this command)
2. Database update can also be automated by an administrator by enabling the DAILY_UPDATE option in /etc/updatedb.conf
# locate new
(it searches for the file with “new” in the name or path, Example: new, renew, /wali/newdir/file1)
-i to perform a case insensitive search
-n X list only the first X matches
FIND Command
Search by name:
# find / -name passwd
(passwd file in / )
# find / -iname wali
[wali, Wali, WALI (case insensitive search)]
# find /root/dump -name *.rpm
(all rpm files from /root/dump)
# find /root/dump -name *.*.conf
(file like my.class.conf)
# find /root -name wa*
[all file / folder that begins with wa (eg. wali, warrior, warm etc)]
# find /root -name ?a*
[all file / folder which second letter is a (eg. wali, man, fast etc)]
Search by user/group:
# find /tmp -user root
(files and folder for the root user in /tmp)
# find /tmp -group student
(files and folder for the student group in /tmp)
# find -user student -group student
(searches for file owned by user student and ground student)
Find and logical operators:
in find command, criteria are ANDed together by default.
Find command can be OR’d or negated with –o (OR) and –not (negate)
and parentheses can be used to determine logic order,
but must be escaped in bash. Some examples are:
# find -user joe -not -group joe
# find / -user joe -o -uid 500
(uid can be used instead of user)
# find -user joe -o -group jane
# find -user joe -o -gid 501
(gid can be used instead of group)
# find -not \ (-user joe -o -user jane \ )
For example, the following will only match files whose names end in .png AND are owned by the user u1:
# find / -name “*.png” -user u1
This behavior can be overridden with the –o option. The following command will match file whose names end in .png OR are owned by student.
# find / -name “*.png” -o -user student
Find also includes a logical NOT operator. Options preceded with a ! or the
–not option will cause find to look for the opposite of the given criterion. So the following command will match files whose names end in .png and are NOT owned by student.
# find / -name “*.png” -not -user student
Search by size:
# find / -size 5M |
files / folder of 5 MB |
# find / -size +5M |
files /folder that are more than 5 MB in size |
# find / -size -5M |
files / folder that are less than 5 MB in size |
Search by permission:
# find / -perm 123 |
file / folder with 123 permission |
# find / -perm -123 |
file / folder with permission less than 123 |
# find / -perm +123 |
file / folder with permission more than 123 |
Search by time:
(-amin = access time, -cmin = created time, -mtime = modified time)
# find /home -amin 31 |
accessed 31 minutes ago |
# find /home -amin -5 |
accessed within 5 minutes |
# find /home -mmin 10 |
modified 10 minutes ago |
# find /home -cmin -10 |
created within 10 minutes |
# find /home -atime 2 |
accessed 2 days ago |
# find /home -ctime 2 |
created 2 days ago |
# find /home -mtime 2 |
modified 2 days ago |





