Using Linux in 351


This course explores low-level topics in machine representation of programs and data. For our reference system, we're using Rocky Linux. Other Linux and Mac OS X systems are very similar, and Windows machines also use the same underlying processors and memory organization. But for assignments in this course, your submissions need to work on, and will be graded on, our reference system.

This is a quick little tutorial on how to get yourself up and running on Linux. If you are a CSE major, then you have access to departmental servers collectively called attu (actually reached at You are welcome to use attu or the , which are running the same Linux image. If you are using the CSE virtual machine, then read just “Shell on Linux” and then from “Finding your way around the shell” onward.

Getting a Shell

The shell is the bread and butter of Linux. I know – graphical things are nice – but the Linux shell brings you a lot of power with not very many key presses. As computing becomes more and more prevalent across all industries, you may find yourself using a Linux shell at some point, so it's a good skill to have/know.

Shell on Windows

Avoid Window's Command Prompt, which looks like a command line interface but uses a different set of commands and tools and behave differently than the shells on Mac and Linux. Instead, you can connect to attu using any of the following methods:

  • PowerShell: Windows 7 and up come installed with PowerShell, which is a hybrid between Command Prompt and a Linux terminal. It does, however, recognize the ssh and scp commands, which is all that you will need for this course.
  • bash: If you are running a 64-bit version of Windows 10 and have installed the "Anniversary Update" (released Aug. 2016) then you can enable a bash terminal (command line interface) directly within Windows! Newer machines can directly from the Microsoft store, otherwise, here is one useful link for .
  • PuTTY: A lightweight SSH client that lets you interact with another computer over the Internet (like opening a shell). You can directly download onto your computer.

Shell on Mac OS X

The Mac OS X Terminal behaves very similarly to most Linux shells. As a result, most of the commands on Terminal will be the same as those from a Linux shell. However, to use the Linux shell commands for 351, we will connect to attu.

  • Click the Spotlight Search button in the upper-right, type "terminal", and press return.

Shell on Linux

You won't need to do any special setup on Linux, as you have a shell installed. It is still recommended that you connect to attu to ensure that you have all of the tools needed and are using the same environment as everyone else.

  • Click Applications at the top, mouse to Accessories, and click Terminal.

Logging onto attu

attu is a powerful computer sitting in the CSE building that is ready to run your work, except that it has no screen. It runs linux, and can only be accessed over the network. You will be granted an account (your UWNetID) on attu for the quarter. attu has all of the commands that you will need in the 351 labs, and is built to be fast, so more often than not it's most convenient to run lab programs on attu.

Accessing attu from Windows (PuTTY)

  1. Open putty.exe from wherever you downloaded it.
  2. For the host name, type <your-csenetid>
  3. Click Open at the bottom.
  4. If you're prompted about an RSA key, click Yes.
  5. Put in your Kerberos password when asked for a password. It will look like you're not typing anything – that's done on purpose so people looking over your shoulder won't know your password.

Accessing attu from Windows (bash), OS X, or Linux

  1. Open the shell on your computer (see "Getting a Shell" above).
  2. Now that you have a terminal up, type ssh <your-uwnetid> and press [Enter].
  3. If prompted about a server key, type yes and press [Enter].
  4. When prompted, enter your Kerberos password and press [Enter]. Like PuTTY, it won't look like you're typing. This is done on purpose :)

Changing your attu password

If you would like to change your Kerberos password, type passwd into the command prompt and press [Enter], then follow the instructions given.

Finding Your Way Around the Shell

How files and folders work on Linux

First off: folders are a fancy word that Microsoft invented to make computers seem more human. While folders are great, they're called directories on Linux.

The first thing that most new users shifting from Windows will find confusing is navigating the Linux filesystem. The Linux filesystem does things a lot more differently than the Windows filesystem.

The Root Directory (/)

For starters, there is only a single hierarchal directory structure. Everything starts from the root directory, represented by '/', and then expands into sub-directories. Where DOS/Windows had various drives (C:, D:, etc) and then directories under those partitions, Linux places all the drives under the root directory by 'mounting' them under specific directories. The closest parallel to the root directory in Windows would probably be C:.

Another point likely to confuse newbies is the use of the frontslash '/' instead of the backslash '\' as in DOS/Windows. So c:\windows\system would be /c/windows/system. Well, Linux is not going against convention here. Unix has been around a lot longer than Windows and was the standard before Windows was. Rather, it was DOS that took the different path, using '/' for command-line options and '\' as the directory separator.

Your Home Directory (~)

To keep people (users) from stepping on each other's toes, everyone has one directory ("folder") that they can write and make changes to. This is called your "home directory". On any Unix system, you can refer to the home directory with a tilde, so a folder called frogs inside of your home directory would have a path like: ~/frogs.

When you run a command, your shell will replace ~ with the path to your home directory. If you want to know what that is or how to manipulate the shell, read the next section on basic Unix commands.

Other Important Directories (. and ..)

The shell also allows you to directly reference directories relative to your current working directory. '.' represents the current working directory. '..' refers to the direct parent of the current working directory. Every additional '.' refers to the directory one level higher.

This can be pretty handy in working your way around your directory structure. For example, if you are in the folder lab1, a sibling directory lab2 would be referred to as: ../lab2.

Basic Unix commands

To move around through the directory structure in your terminal window, you'll need to know a few basic Unix commands. Note that you always start in your home directory when you open a terminal.

To get help on some command, say you want to know how to use ls, type "man ls" and you will get the manual pages for that command. (Alternatively, you can use "info" in the same way.)

Command Function Example Explanation Notes
mkdir Creates a new directory with the given name in the current working directory. mkdir lab1 This will create a new directory called "lab1".
ls Lists all directories and files in the current directory. ls -A This will list all sub-directories and files. The -A flag means that hidden directories and files will also be printed to the console. Check the manual page for ls to find out various flags to show directories and files in different forms.
cd Navigates to the specified directory, given its relative path. cd lab1 This will navigate to the lab1 directory inside the current directory. This is a common place where . and .. are used. Also, to use a directory's absolute path, start the directory name with either / or ~. For example:

cd ~/cse351/lab2

pwd Prints the current working directory path. pwd This will print the current working directory's absolute path to the console.
exit Exits the console, or logs out of the current SSH session. exit This will terminate the current terminal window. If you are SSH'd into attu, this will terminate your session.

Here is a sample execution of some Unix commands. The [attu]$ is just the prompt telling you that you're logged into attu. Lines that don't start with this prompt are output returned by the shell in response to the previous command.

[attu]$ mkdir mydir
[attu]$ ls
mail  mydir
[attu]$ cd mydir
[attu]$ pwd
[attu]$ exit

These are just the very minimum basics, of course.

Changing your shell

The shell is the program where you type in commands. There are different shell programs, which are all similar but have different rules and features. For sake of uniformity, we will use a shell called "bash," and your account should be set-up to use this by default. You can check using the following command: [attu]$ echo $0.

In case the output isn't bash or -bash (or you're updating your personal Linux machine), you can change the shell temporarily or permanently. We strongly recommend the latter, but we'll explain the former first to help you understand what is going on.

Temporarily: Type [attu]$ bash.

Now you may have a different-looking prompt (such as [bash-3.00]$), but otherwise at this point you will not notice any differences. Note that instead of changing your shell, you've actually opened up a new shell (we'll discuss processes in this course), so when you type [bash-3.00]$ exit, you'll actually return to the original shell (the one you typed bash into).

Permanently: Instead, you can tell the operating system that the "first shell" for every terminal should be bash for your account. From any prompt, type: [attu]$ chsh -s /bin/bash.

You are running the "change shell" program and specifying that your new shell can be found at /bin/bash. It's almost that simple:

  • To be sure you have the right to do this, you'll be prompted for your password.
  • Before that, you'll be warned that typing passwords can be dangerous. Say "y".
  • As the message says, the change may take a few hours. In the meantime, see the "Temporarily" instructions above.

As a final note, if your shell already is bash, chsh will just say "Shell not changed."

Editing Files

First thing's first: There is a ton of debate about this.

CSE 351 Text Editing

For this course, you can use something as simple as Notepad. However, we strongly recommend something better to help you read and debug your code. Here is a list of text editors, listed by OS, that we recommend:

Copying Files to Attu

Work locally

Download the necessary files to your machine's hard drive (directly from the web or attu), then use a text editor to make changes. After that, you'll need to copy the updated text files back to attu using one of the following suggested methods:

  • scp (from a shell) Uses the command line interface you'll be getting accustomed to in this course. A quick overview can be found on this blog post.
  • FileZilla GUI version of SCP that allows for drag-and-drop and limited remote file system manipulation (e.g. file renaming, file deletion, file permissions, directory creation). Works on all platforms (Windows, MacOS, Linux).
  • WinSCP (Windows only) GUI version of SCP that allows for drag-and-drop and limited remote file system manipulation (e.g. file renaming, file deletion, file permissions, directory creation).


Viewing all of the output when you run commands

When you run a command like btest on attu, you may see something like the following:

  Gives 1942614435[0x73c9f1a3].  Should be 204869213[0xc360e5d]
... 9 total errors for function abs
Test abs score: 0.00/4.00
Test addOK(-2147483648[0x80000000],-2147483648[0x80000000]) failed.
  Gives -2147483648[0x80000000].  Should be 0[0x0]
Test addOK(-2147483648[0x80000000],2147483647[0x7fffffff]) failed.
  Gives -2147483648[0x80000000].  Should be 1[0x1]
Test addOK(-2147483648[0x80000000],-3[0xfffffffd]) failed.
  Gives -2147483648[0x80000000].  Should be 0[0x0]
Test addOK(-2147483648[0x80000000],811666840[0x30610d98]) failed.
  Gives -2147483648[0x80000000].  Should be 1[0x1]
Test addOK(-2147483648[0x80000000],-2147483647[0x80000001]) failed.
  Gives -2147483648[0x80000000].  Should be 0[0x0]
... 321 total errors for function addOK
Test addOK score: 0.00/3.00
Overall correctness score: 14.00/36.00
1541 errors encountered.

What happened to the first part of it? Answer: it scrolled up past the top of your terminal. You'll have to tell attu you want to see all of that output.

Save as a file: If you run btest (or any command) as follows:

[attu]$ ./btest > feedback_filename

Linux will save its output in the file called "feedback_filename" (careful, it will overwrite existing files) for you to view later in your favorite text editor.

View output screen-by-screen: Instead, run:

[attu]$ ./btest | less

You can then use the up/down arrow keys to move around your output in a quick and dirty fashion. Use the 'q' key to quit. Be aware: Once you quit, the output is gone for good! But, luckily for you, you can just re-run btest to get it back. You can also use less to view the output from your saved file, like less feedback_filename.

Make clean and corrupt builds

Not everything is perfect, sadly :(. One of those is our build system. Though it is unlikely, the rule of thumb when running the make command is:

  • If something really doesn't look like it's running right, do a make clean, then a make and try it again.

To save time, make and gcc will save some of the computation required to build your software. However, at times, this can become corrupt and interfere with changes you're making.

Written by Andrew Reusch ( Updated by Sarang Joshi (, Justin Hsia (, and Andrew Hu (