DEV Community

abbazs
abbazs

Posted on

How to find the folder location of a command in linux?

To find all the folder locations where ls command is found:

type -a ls
Enter fullscreen mode Exit fullscreen mode

Returns

ls is aliased to `ls --color=auto'
ls is /usr/bin/ls
ls is /bin/ls
Enter fullscreen mode Exit fullscreen mode

Suppose there is a command by name ffbn and you want to know more about it:

type -a ffbn
Enter fullscreen mode Exit fullscreen mode

Returns

ffbn is aliased to `find_file_by_name'
Enter fullscreen mode Exit fullscreen mode
type -a find_file_by_name
Enter fullscreen mode Exit fullscreen mode

Returns

find_file_by_name is aliased to `find_file_by_name'
find_file_by_name is a function
find_file_by_name () 
{ 
    find . ! -readable -prune -o -type f -name "$1" -print
}
Enter fullscreen mode Exit fullscreen mode

Indeed type command is super useful to know about a command.
Documentation
Further help

Top comments (0)