Skip to content
RIPE NCC member · Local Internet RegistryCall us on 020 3318 3449sales@hosting-telecom.uk

Where a program is located: which, command -v, whereis

How to find the full path to a program, why a command isn’t found, and which package a file comes from.

Contents
command -v php
/usr/bin/php
command -v namethe path to the program that will run under this name; works in any shell and is handy in scripts
which -a nameevery program with this name, in the order the system searches for them
type nametells you if the name is not a program but an alias or a built-in shell command
whereis namewhere the program and its manual page are located

Why a command isn’t found

Programs are searched for in the directories listed in the PATH variable; to see it, run echo $PATH. If a program is installed but you get “command not found”, its directory is not in PATH: run it by its full path or add the directory to PATH. For the same reason, it is best to always use full paths in cron — it has its own short PATH.

To find a program file anywhere on the disk: sudo find / -name 'name' -type f 2>/dev/null.

Which package a file comes from

Ubuntu, Debiandpkg -S /usr/bin/php
AlmaLinuxrpm -qf /usr/bin/php
FreeBSDpkg which /usr/local/bin/php

Didn’t find the answer? Ask our support team — we’ll help.

Choose which cookies we may use. You can change your mind at any time with the “Cookie settings” link at the bottom of every page.

Necessary

Always active

They keep the site secure and remember your cookie choice. They don’t identify you.

Google Analytics counts visits and shows which pages people find useful, so we can improve the site. Which cookies