Title image Tutorial

Navigating multiple computers with the Terminal

This is a quick tutorial about how to use the Terminal to navigate the computers in Bobs 225, the Natural Sciences Computing Cluster (nscc), and computers hosting our GPGPUs in the Schufp Lab. It starts simple, but then ramps up a bit.

Basic Terminal tutorial*

First, orient yourself to the terminal application on your own computer. This section is a quick tutorial on how to use the Terminal application and get around a computer using the command line.

Open up the Terminal application, which is a text-based method of using your computer.

A terminal is simply a text-based interface to the computer. In a terminal, you can type commands, manipulate files, execute programs, and open documents. When working in a terminal, the current directory is called your working directory. A terminal will usually start in the top-level directory of your account.

Directories are separated by a slash /. The topmost directory is indicated by a single slash. The total directory tree is all relative to the top level directory.

On MacOS, there is a Volumes directory at the top that lists all mounted drives (networked or local). So if you have mounted your network directory, the path to it will look like the following if you substitute your username for mine.


In a terminal, you generally type a command and any modifiers or arguments the command requires, then hit return and the command is executed. For example, to set your current (working) directory to your home directory, type cd and the prompt and hit return. Below is an example of a terminal and some commands.

Note that pretty much all of these things you can do using the Finder on a mac or the desktop on Windows. Once you learn the command set, however, you may find that certain actions are much faster using a terminal (opening or deleting all files in the current directory that end with .png, for example). As you begin to use the commands, relate then to actions you already know how to do.

Some common useful terminal commands include the following.

*Note: This tutorial is essentially the one written by Bruce Maxwell. It has only a few minor edits.

Shell tutorial

Now for the more advanced part. The Terminal program is running what is called a "shell" - the standard term for a command line interface in a Unix operating system. The shell allows you to access information that "low level" programs (such as the C compiler) use to find files and garner other necessary information.

One important aspect of the shell is that it allows you to get and set environment variables, which are basically variables containing information about the computer. One of the most important environment variables is PATH. It contains a colon-separated list of directories. When you run a program from the command line, the OS needs to find it somewhere (for example, where is ls?). It searches through each directory in the PATH until it finds the file, and then executes it.

Below I print out the value of PATH - the value is accessed using the $. Then, I ls and it works. But where is it? I run the program which and learn it is in /bin/. Then, I list the files beginning with l in that directory. Lo and behold, it is there. Note also that /bin is on the list of directories in PATH. It all makes sense!

There are two popular shells, with slightly different sets of commands. All share the commands listed above in the Terminal tutorial. But it is important to know that there are multiple shells out there. Two of the most popular are called tcsh (for TENEX C shell) and bash (for Bourne again shell). The Macs use bash and NSCC and gpu0 use tcsh. We will spend most of our time in tcsh shells.

When you open a new tcsh shell, the OS looks for a file named .cshrc (for C shell resource) in your home directory. This file should contain shell commands that help you personalize your set-up. For us, this means we add directories to our PATH.

This makes a difference to you. Why? In general, the path environment variable does not contain the current directory (./). So, if you are writing C programs and placing your executables in the same directory, then you won't be able to run the executable without telling the OS where it is. In other words, if you make hello world like this:

gcc -o hello hello.c

you won't be able to run it simply by typing hello on the command line. You will instead need to type ./hello to tell the OS that the executable file hello is in the current directory. If the OS is told exactly where the executable is, it won't bother consulting your path environment variable.

SSH tutorial

SSH is the program that allows us to log onto another computer and run a shell on it, securely. Not surprisingly, it stands for "Secure Shell".

See below for an example. I demo that I am on my computer, by showing which directory I am in and what it contains. Then, I ssh into nscc. I show my home directory and its contents there.

If we use the X-forwarding feature of SSH, we can display a program's GUI (if this program is using X graphics) from the remote machine on our machine. We will need to do that in order to edit files on NSCC and GPU0. We will be using XEmacs - an X-Windows-based text editor. To use X-forwarding, we use the -Y switch (why not -X? good question. the short answer is that it should be possible to use -X, but that we have an odd setup with the GPU-hosting computers and need to use -Y).

Once you have finished your work on the remote computer. Type exit to end the ssh session.