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?

Foam Seat Cushion

Aching back from coding all day? Try Back Problems

This foam seat cushion relieves lowerback pain, numbness and pressure sores by promoting healthy weight distribution, posture and spine alignment. Furthermore, it reduces pressure on the tailbone and hip bones while sitting. Perfect for sitting on the computer desk for long periods of time.

$ Check price
99.9599.95Amazon 4.5 logo(9,445+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

System Admin Handbook

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

This book approaches system administration in a practical way and is an invaluable reference for both new administrators and experienced professionals. It details best practices for every facet of system administration, including storage management, network design and administration, email, web hosting, scripting, and much more.

$ Check price
74.9974.99Amazon 4.5 logo(142+ reviews)

More Linux & UNIX resources

Ad