How to find a file with Linux using the command line.

Posted: March 2, 2014. At: 9:13 PM. This was 3 years ago. Post ID: 6731

The Linux command line offers useful tools that enable you to find files easily. The find command is one useful example.

Here I am using the find command to look for all *.png files in a folder.

[email protected] ~/Documents $ find /usr/share/backgrounds -name "*.png"

And using wildcards to find all files with init in their name.

[email protected] ~/Documents $ find /lib -name "init*"

This is how to find a file from the root directory and suppress all errors.

[email protected] ~/Documents $ sudo find / -name "vmlinuz" 2> /dev/null
[sudo] password for homer: 

Another example.

[email protected] ~/Documents $ sudo find / -name "vim.tiny" 2> /dev/null

The locate command for Linux also allows you to search for files on your Linux system. Below is an example.

[email protected]:~/c-plus-equality ☠ $ locate vim.tiny

Use the updatedb command to update the database for the locate command.

[[email protected] boot]# updatedb

These commands allow you to find files on your Linux system very easily. Here is a final example; using the find command.

[[email protected] boot]# find / -name 'vmlinuz*' 2> /dev/null

Comments have been closed/disabled for this content.