Locating Executables with PATH
Learn how to locate executables with the PATH variable.
We'll cover the following
An overview of PATH
When we type commands like cd
or ls
, we’re executing a program. The PATH
environment variable contains a colon-delimited list of directories the OS uses to look up executable programs.
We print out the value of the PATH
variable with echo
:
$ echo $PATH
The which
command tells us where an executable is located on the filesystem by looking through all the directories in the PATH
and displaying the first instance it finds. Let’s try it out with the ls
command:
$ which ls
Use the terminal below to practice these commands.
Get hands-on with 1200+ tech skills courses.