Chapter 1: Warming up to the Linux Terminal

Commands

face Robert Craven

Programs run from the terminal can take arguments and options. An argument often gives the data the program runs on. An option tweaks how the program runs.

Let’s tell ls to list the contents of a different directory. Type the following and hit return:

username@MACHINE:~$ ls /etc

We’ve given ls an argument—told it to list the contents of the directory /etc, instead of your home directory.

Let’s give it an option flag instead. Type the following (this is a number 1):

username@MACHINE:~$ ls -1

This will again list the contents of the current directory (your home directory), but in a single column.

We can combine the two:

username@MACHINE:~$ ls -1 /etc

We’ve listed the contents of /etc, and done this in 1 column.

Exercise 1

  1. List the contents of the directory /usr.
  2. Now list the same directory, but print the results in one column.
  3. Use ls with options -sh to list the sizes of the contents of usr.
  4. Can you work out how to list the sizes of the contents of /etc in a single column?

Clearing the terminal

After printing all that information in the terminal, you might want to clean it!

Try Ctrl+L (without return) to move the prompt back to the top of the terminal window.