Linux / UNIX: Determine where a binary command is stored / located on file system

You can use “type” or “whereis” command to find out which command shell executes and to print binary (command) file location for specified command.

ADVERTISEMENTS

whereis command example

Display ls command location along with man page path:
whereis ls
Output:
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz

type command example

Find out which command the shell executes:
type -a ls
Output:
ls is aliased to `ls –color=tty’
ls is /bin/ls

Related: How Linux or UNIX Understand which program to run – PART I and How BASH Shell Command Search Sequence Works

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
4 comments… add one
  • Corey Hart Aug 29, 2007 @ 20:06

    If for some reason the command you are looking for is not in your PATH you can try the locate command to find out where it might be located

    % locate ls

  • Kunal Oct 27, 2007 @ 14:16

    i access my server through sshd using putty but after a certain period of time the port on which sshd is open is closed automatically.
    i am not able to figure out this problem.
    please help me thanks in advance

  • Pramoth Jun 24, 2009 @ 12:12

    How to know the virsion of a binary file in UNIX?
    Need unix command for the same.

    • Tolli Mar 2, 2013 @ 20:56

      Typically programs have a version command line option to print the version number. Try running ‘program -v’ or ‘program –version’. Some binary files on your system are actually a link to a specific version of that program. For example, on my system, /usr/bin/python is a link to python-2.7, so I know that I have python version 2.7. (to see if a file is a link run ‘ls -l /path/to/file’ and it will have a ‘l’ at the beginging of the line, and have an arrow at the end followed by the file that the link points to).

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.