DEV Community

abbazs
abbazs

Posted on

2

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

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs