Three search commands that Linux users are sure to use.

Medium 6381538651

photo credit: paloetic via photopin cc

Good evening, this is Bono.

Often when I connect to another PC via a Mac terminal or SSH connection, I want to search for files using Linux commands.

Here we write down three search commands that have been used dramatically more frequently in the past.

It is not a particularly special command, but it is worth learning for beginners.

Three search commands that you will definitely use

Search by file name

The most basic way to search. Put the name of the file you want to find, such as hoge.html, in the file name field, and it will output all of the files.

[crayon] find / -name filename
[/crayon]

Searching for files with a certain string

This is a command that I use quite often, along with the above commands. If you put the string you want to search for in the string field, it will output all the files that contain that string.

[crayon] find / -name "*. *" -exec grep -l "string" {} ;
[/crayon]

Search by directory name

This is another command that I use often, though not as often as the above two. Put the name of the directory you want to search in the directory name field, and it will output all the directories that contain it.

[crayon] find / -name directory name -type d
[/crayon]