Finding Files in Linux
Check if locate is installed
If it is installed, it’ll give you the path
yum install locate
apt-get install locate
The locate command uses a database of file names and locations. That database is updated frequently via a system cron job.
Find is verstile and powerful. We can search files based of the permissions a file has. We can find by modification date or how long ago the file was created. Regex can also be added. Search based on text inside a file..
find /etc -name "motd"
will find files in the /etc directory where file name is “motd”
find /etc -name "motd*"
will find files in the /etc directory where file name starts with ‘motd’
By default, the
-name flag is case sensitive.
-iname will search by file name, case-insensitively.