Linux: Search/Find Command
Find Command Location
which cmd-
Show full path of a command, useful for checking if a program is installed.
The
whichcommand search for the command in$PATHenvironment variable. If it returns nothing, it means the command is not in the$PATH, yet it may be installed somewhere.Try
echo $PATH. It is a list of dir paths. They are searched in order.
Find a file by name using locate
locate fname-
Find a file by name (using the database see
man updatedb). This is similar tofind dir_paths -name "*fname*"but much faster. updatedb-
Update the database used by
locate. (this is done automatically. Useful only if you just installed bunch of new commands.)
Show Type of Command
type cmd-
Show if cmd is a shell built-in or standalone program. For example,
type kill. The commandtypeis a built-in bash command, not a standalone shell util. Trytype type
Excutable files must have executable bits on. That is, the “x”. For example, type ls -l /usr/bin to see them. 〔see Linux: File Permission System〕