locate is used to search for files and directories it is similar to find but only searches on the filename sudo updatedb β updates locate's DB locate aaa.txt β searches for aaa.txt locate *.txt -n 5 β searches for files with txt extension and shows only 5 locate *.TXT -n 5 -i β searches with case insensitive match locate *.TXT -c β returns only the number of matches common options: -l β limits the number -q β quiet mode -r β use regex pattern
b - find command
find command is used to search for files and directories The search is based on various criteria like name, size, date etc. syntax β find [path] [options] [expression] find . -name aaa.txt β searches for file aaa.txt in current directory find . -type d -name dir1 β searches for dir1 name in directories find . -type d -name 'd*' β searches directories starting with d find . -user root β searhes for files/directories owned by root common option: -perm β specifies the permission of the file -group β specifies specific group. -mtime βspecifies the modification time -atime β specifies the access time