CSC 161 Grinnell College Spring, 2009
Imperative Problem Solving and Data Structures

Basic Linux Commands and Capabilities


The original Unix operating system and its successor Linux were designed to support the common tasks and needs of computer users. This laboratory exercise reviews some basic commands and capabilities that match likely needs of CSC 161 students.


This lab covers the capabilities and commands for a terminal window in the following table. The subsequent lab considers the remaining capabilities and commands for the table.

Topic Category Subtopics Linux Commands
Terminal Window open  
change password password
copying between windows  
terminal utilities sleep, history, arrow keys, cat
background process  
Directories and Files paths ., .., ~, /, pwd
pathnames absolute, relative, pwd, cd, ls, which, whereis
file utilities mkdir, rmdir, rm, cp, mv, more, head, tail, pushd, popd
Help manual man
Printing printing lpr, a2ps, lpq, lprm
Permissions user, group, world ls -l
setting permissions chmod
start up .bashrc, .bash_profile, umask, alias

Before progressing further in this lab, be sure you have completed the readings for this lab.

The Terminal Window

For most of this lab, you will be experimenting with a terminal window.

Opening the Terminal Window

  1. You may already have a terminal window on screen. If not, start one by moving the pointer onto the small monitor icon on the bottom row of the front panel, and click with the left mouse button.

  2. Set the window aside for the moment (e.g., minimize the window) by clicking on the small bar or underscore character at the upper right-hand corner of the window, and restore the window by moving the pointer onto its icon and clicking the left mouse button.

Changing Your Password

  1. Choose a new password. Make it something that you can easily remember, but not an English word or a name, since it is easy for system crackers to break in by guessing your password if you choose it from one of those categories.

    Use the password program within a terminal window to change your password.

Cutting and Pasting Between Windows

  1. Open Dr. Scheme in addition to your Internet browser containing this lab.
    1. Consider the following Scheme definition:

         (define mult5 
             (lambda (n)
                (* n 5)

      Select this material as follows: move the cursor to the beginning of a section and push down the left mouse button. Then, holding the button down, move the mouse to the end of the section. (The entire section now should be highlighted.) When the desired section is highlighted, stop pressing on the left mouse button — the section should stay highlighted.

      In preparation for later in this lab, save the resulting Definitions' Window in Dr. Scheme as the file my-test-file.

    2. Move the mouse to the definitions window of Dr. Scheme, and click the middle mouse button to paste the definition into Dr. Scheme.

    3. Can you paste this definition into Dr.Scheme's Interactions window and into a terminal window?

Terminal Utilities

This section asks you to practice with several useful commands within a terminal window.

Stopping a Long or Infinite Loop

  1. Within a terminal window, launch the sleep utility for 10 seconds:

       sleep 10

    Kill processing in the window with ctrl-c.

The Arrow Keys

  1. Move your mouse to a terminal window, and type several commands (e.g., use cat to display several Scheme programs you have saved during your previous CSC 151 course) and use the sleep command a few times. (This work creates a past record of work you have done in this terminal window.)

  2. Use the up-arrow key to retrieve several previous commands. Then, use the down-arrow to move to more recent commands.

  3. After you have retrieved the sleep 10 command, use the left-arrow key and then the delete key to edit the line to sleep 5. Then hit return and note what happens.

  4. Now use the up-arrow and left-arrow key to type a 1 before the 5 to produce sleep 15. (Do not use the right-arrow key to move the cursor to the end of the line.) Hit return, and use your watch to determine how long the sleep lasts. Note that you can edit any part of a line and then hit return to enter the entire line into the terminal window.

  5. Type history into the terminal window to get a list of recent commands you have issued in this terminal window.

  6. To re-issue a command, type an exclamation point followed by the command number from the history command. For example, suppose history gave you the list

      505  sleep 10
      506  history

    Then typing "!505" allows you to re-issue the sleep command.

    Now re-issue the history command in this way.

Background Processes

  1. Suppose you want to read the pdf file ~walker/c/examples/examples.pdf with the acrobat reader.

    First, type

       acroread ~walker/c/examples/examples.pdf

    This will open acrobat reader just fine, but now switch back to your terminal window. You will notice that it is unavailable for further use (i.e., you won't get another command prompt) until acrobat reader is closed.

    Now close acrobat reader, and then re-open it from the terminal window, but this time add an ampersand character to the end of the command:

       acroread ~walker/c/examples/examples.pdf &

    Now when you return to your terminal window, a prompt is waiting for you, making it easy to do multiple tasks at once. Adding the ampersand character to a command causes the command to be launched as a "background process," allowing you to continue working with your terminal window.

Adding the ampersand character to a command causes the command to be launched as a "background process," allowing you to continue working with your terminal window.


  1. Try using "autocompletion" with the file my-test-file by typing"cat ~/my-t" followed by a TAB key. You should find that when you press TAB the system completes the (unique) file name for you. Note that on the Campus Linux Network, when you type the tilde character "~" in the terminal window, the character will LOOK like a hyphen "-" instead. Even so, the system will interpret it as a tilde. (The command name cat stands for "concatenate" for reasons we will see later. It can be used to display the contents of a text file, so you should see the file my-test-file scroll by when you use this command.)

  2. Create a new file my-test-stuff using Dr. Scheme or another editor.

    What if you press TAB too early, such that there isn't a unique completion? Try this by typing cat ~/my-t, followed by TAB.
    Hit TAB a second time to see how the system responds.

    What happens if you type cat zqrz followed by TAB (where I am assuming you do NOT have a file zqrz)?

  3. Note that autocompletion also works with commands. For example, try typing his followed by TAB.
    What is the fewest characters you can type to produce the history command?
    What other commands begin with the letter h?
    Are there any commands that begin with her?

Closing a Terminal Window

  1. Try closing a terminal window by typing Ctrl/d

This document is available on the World Wide Web as

created 31 March 2008
last revised 25 January 2009
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at