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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay