02. Introduction to the Shell $PATH, cal, exit

When we talk about the command line we actually are referring to the shell. The shell takes whatever you type in, searches for that command in the directories list in your $PATH variable then runs them through the operating system.

Checking the directories in $PATH

To take a look at the $PATH variable type echo $PATH.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Each directory is separated by a colon (:). We'll look more in-depth about the $PATH variable, and the echo command soon.

Viewing available binaries

For now, let's look at the contents within one of the folders in our path. We can do this with the ls command. Let's look in one of our bin folders, which is short for binaries.

$ ls /usr/bin
... corelist cpan cpan2dist cpanp cpanp-run-perl cpp cpp-4.8 crc32 ...

You should get a long list of commands that are available to you. We'll learn more about folders, the file system and the ls command soon, but just know that the commands you enter in the command line actually come from executable files and not from thin air.

Now try typing some random letters into your terminal.

$ asdf
-bash: asdf: command not found

You should get an error. This is because it's not a command that lives in one of our $PATH directories.

A simple command

Now try the calendar command, cal, which outputs the current month's calendar.

      May 2016        
Su Mo Tu We Th Fr Sa  
 1  2  3  4  5  6  7  
 8  9 10 11 12 13 14  
15 16 17 18 19 20 21  
22 23 24 25 26 27 28  
29 30 31 

There are tons more commands you can use, and even more you can install and write yourself!

In this tutorial series, we'll learn the most commonly used commands, and learn some practical concepts of using the Linux Command Line. Through learning about the commands, we'll slowly begin to transition into learning about the Linux Operating System as a whole.

Exiting like a champ

To exit the terminal from the command line, use:

$ exit

Aching back from coding all day?

Acupressure Mat & Pillow

Aching back from coding all day? Try Back Problems

Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.

$$ Check price
144.87144.87Amazon 4.5 logo(1,890+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Ad