These pages are meant for students new to the SwatCS computers.

After working through the sections in the Table of Contents on the left, you should feel comfortable using some basic unix commands in the terminal window.

And don’t feel like you have to remember it all after one session. Feel free to return to these pages anytime to refresh or learn more. The more comfortable you are with unix commands in the terminal, the more efficient you will be getting your CS labs done!

UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.
— Dennis Ritchie

logging in

You’re probably already logged in, so this may be unneeded, but the initial login screen on the lab machines should look something like this:

lab machine login screen
  • you should have already been given a CS username and password (if not, see your professor)

  • just enter your CS username and password

  • Note: these computers are different from the ITS computers on campus. We run linux on these computers, and only students taking CS have accounts on these computers (which is why your CS password is different from your ITS password)

  • if you’ve forgotten your password, try our self-service password reset page

  • if you still have trouble logging in, or any questions about the CS computers, send an email to local-staff at

window manager

The default window manager we use is xfce. Once you log in, the screen should look something like this:

default desktop

We will run various unix commands in the terminal window.

Open up a terminal window with a single click on the terminal icon in the dock.

After you open a terminal, your screen will look something like this:

desktop with terminal


If you didn’t already change your password on the first day of class, or if you just want to change it again:

  • run the passwd command in a terminal window

  • it will ask for your current password once and a new password twice

  • note: the passwd program doesn’t show any stars (****'s) when you type your passwords (see screenshot below)

  • please protect your CS account with a good password!

  • CS passwords should be:

    • 8 or more characters in length

    • contain mixed case letters

    • contain at least one non-alphabetic character

example password change

Note: if you ever forget your password, you can use our self-service password reset page:

directories (aka, folders)

Your home directory (some people call them folders) is part of a tree-like structure:

directories example
  • the full path to hpotter1’s home directory is /home/hpotter1

  • the full path to hpotter1’s 01 directory is /home/hpotter1/cs21/labs/01

  • you can use the pwd command to print your working directory (where in the tree you currently are)

Try this example! And the dollar sign ($) below is just the unix prompt (yours might look slightly different). You don’t type the dollar sign, just everything after the dollar sign.

And when we say "run this command", we mean type it in a terminal window.

$ pwd

The above should display /home/username, where username is your actual CS username (like hpotter1, or ssquarp2). When you first log in and open up a new terminal, you are always in your home directory (/home/username).

Try this example, too!. Let’s make a sub-directory called testdir, just for testing:

$ mkdir testdir

The mkdir command makes a new directory (there’s no output or anything if the command worked).

In the next few sections we’ll see how to view our files and change into different directories, like the test directory we just made.

changing directories

We use the cd and pwd commands to change directories and display where we are.

Try this!

$ pwd
$ cd testdir
$ pwd

The first pwd should display your home directory. Then the change directory (cd) command moves you one level down in the tree, to your newly-created testdir. And the last pwd should display /home/username/testdir.

Users new to UNIX are often confused by paths and directories. A full path lists out all directories, from the root, like /home/hpotter1/cs21/labs/00. You can always use a full path, but it’s sometimes quite long.

What does cd .. do? Try it and see if you can figure out where it puts you in the directory tree (hint: use pwd)!

If you use cd .. enough times, you will get to the root of the directory tree (slash or /):

$ cd ..
$ pwd
$ cd ..
$ pwd
$ cd
$ pwd

Note: you can always use cd by itself to get back to your home directory (see the last cd in the above example).

listing your files

The ls command is short for list. You can use the ls command to see your files and directories (folders). You can also list out files in another directory using the full path (with the slashes in it — see below).

Try these examples! And anywhere it says username, please type in your user name, like hpotter1 or gwashin2, etc.

$ ls
$ ls testdir

The first ls above displays a few files and directories in your home directory. You don’t have much at this point (I think it just shows testdir, Desktop, and Documents).

The second ls above displays everything in your testdir directory, which is nothing at this point, since we just made that. In the next section we will add some files to that directory.

Try these, too.

$ ls ~jk
$ ls ~jk/inclass
$ ls -l ~jk/inclass

The first ls above lists out the files of user jk. This is something you might do when copying files from your professor. In the output of the first ls command, you should see an inclass/ entry. The slash at the end of inclass indicates it is a directory.

The second ls above lists the files in the /home/jk/inclass directory (~jk is shorthand for /home/jk).

The last example above uses the -l (lower-case L) option, which shows the long format for listing files. This shows extra info on the files and directories, such as the owner (jk) and size of the file, and who has access to read and write the file.

In the next section we will copy the file into our testdir, so we can view and edit the file.

copying files

The cp command is used to copy a file. The format of the command is cp file newfile, and this makes a copy of file called newfile.

For example, to make a backup copy of a file named, you could run cp

Try this! Let’s change into our testdir directory and then copy the file from user jk:

$ cd testdir
$ cp /home/jk/inclass/
$ pwd
$ ls

The above pwd output should show you are in your testdir directory. The ls should now show you have a copy of in your testdir directory.

Remember: if you’re ever lost, a simple cd command will put you back in your home directory (/home/username).

One more to try! Copy over the unix_commands file from our /scratch/usingunix directory:

$ cp /scratch/usingunix/unix_commands .
$ ls

Don’t forget the dot (.) at the end of that cp command! Using a dot for the newfile part of the copy command is a shortcut for "name the copy the same as the original file". When you run ls, you should now have a copy of the unix_commands file.

In the next section we will see how to view the contents of a file.

viewing files

Sometimes we want to edit or change a file, and sometimes we just want to see the contents of the file.

To see the contents of the file there are two unix commands: less and cat.

The cat command (short for concatenate) can be used to just dump the contents of the file to the screen. If the file is large, the contents may scroll off the top of the terminal.

Try the cat command! If you are still in testdir, run the cat command on the two files we now have in there.

$ cat
$ cat unix_commands

To view a file one page at a time, use the less command:

$ less unix_commands

Hit q to quit out of less at any time.


There are a variety of text editors on our system. Some students use atom, some use vim, and some use other editors like emacs or sublime.

For CS21, atom is probably the easiest to learn, and you should try that out the first week of class. You can try it out by just typing atom in a terminal window.

Students taking CS31 should learn vim. There is a vimtutor command which puts you into a file and teaches you the basics of vim. Your first lab (lab0) will have more information on using vim and learning the basics.

rename or remove a file

The mv command is used to move or rename a file. The format of the move command is similar to the copy command: mv file newfile. For example, to rename a file from to mv

You can also move a file into a different directory with mv file directoryname

The rm command is used to remove a file. For example, to remove a file called rm

Examples to try!

$ cp /scratch/usingunix/
$ ls
$ mv
$ ls
$ cat
$ rm

The above should copy a file, then rename it, show the contents of the file, and finally remove it. When you remove the file, it will ask "remove", to which you can answer either 'y' or 'n'.

logging in from home

Your Swarthmore College ID cards have a prox tag in them. If you are taking a CS course this semester, your ID should allow you to open the lab doors at any time, day or night, so you can work in the CS labs as much as you want. And we have a lab in the basement of Clothier (C16) that you can use, as well as the three in the science center (238, 240, 256).

If you don’t want to come to the labs, you can still connect to our computers using ssh, which stands for Secure Shell.

On Macs, ssh should already be installed. All you should have to do is open up a Terminal and type ssh -Y (substituting for your username, like hpotter1).

For PCs, you will need a secure shell client, like Putty. On your PC, download and install the putty.exe file and then run it and connect to

More information about remote logins:

logging out

Don’t forget to logout when you are done. It’s best if you quit all applications first, like Browsers, Terminals, and Editors.

After quitting all applications, single-click the logout icon in the dock and then click the "Log Out" button:

logout button


unix commands summary

  • cd — change directory

  • ls — list your files

  • pwd — print your working/current directory

  • mv — move/rename a file

  • rm — remove a file

  • passwd — change your password

examples of the above commands

In this example, the student’s username is hpotter1.

$ pwd
$ ls
Desktop/  Documents/  cs21/
$ cd cs21
$ pwd
$ ls
inclass/  labs/

$ cd inclass/
$ ls
$ cd w01-intro/
$ ls

$ cp
$ ls
$ mv
$ ls
$ rm
rm: remove regular file y
$ ls

$ passwd
Enter login(LDAP) password:
New CompSci password:
Retype new CompSci password:
LDAP password information changed for hpotter1
passwd: password updated successfully

other possibly-useful commands

  • a2ps — prints file to the lab printer

  • sharples — prints out the menus and hours

  • cal or cal 2019 — prints out calendars

For more help documentation:

Any questions about the CS computers, please email local-staff at