We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

PATH

This is one of the most important lessons in this entire course! Listen up.

There are environment variables that are sort of "built-in" to your shell. By "built-in" I just mean that different programs and parts of your system know about them and use them. The PATH variable is one of those.

Why Do We Care About the PATH?

If it weren't for the PATH, you'd have to remember the filesystem path of every executable you wanted to run in your shell. Instead of just running ls, you'd have to run /bin/ls (or whatever the location of the ls executable is on your system). That's not very convenient.

The PATH variable is a list of directories that your shell will look into when you try to run a command. If you type ls, your shell will look in each directory listed in your PATH variable for an executable called ls. If it finds one, it will just run it. If it doesn't, it will give you an error like: "command not found."

What's in the PATH Variable?

Take a look at your current PATH variable:

echo $PATH

You should see a list of directories separated by colons (:). Here in the browser, you'll see:

  • /usr/bin
  • /bin

Each of those directories is a place where your shell will look for executables. A more realistic PATH for your local machine might look like this:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Which means your shell will use all these directories to look for executables:

  • /usr/local/bin
  • /usr/bin
  • /bin
  • /usr/sbin
  • /sbin

Assignment

Print the contents of your current PATH. You should see a colon-separated list of directories. Those are the places your shell looks for the commands you type.

Submit the shell checks.