This Is Not The Course Website You Are Looking For

This course website is from a previous semester. If you are currently in the class, please make sure you are viewing the latest course website instead of this old one.

Here is a general outline of the key concepts and commands (arranged by topic) that you should know for Exam 01.

The exam will have the following format:

  1. Commands: Identify which commands perform certain tasks (multiple-choice).

  2. Shell and Files: Identify ways to perform certain tasks in the shell (multiple-choice).

  3. Networking and Processes: Identify ways to perform networking and process management tasks (multiple-choice).

  4. Pipelines: Describe pipelines, I/O redirection, and the Unix Philosophy (multiple-choice, fill-in-the-blank).

  5. Shell Scripting: Debug, fix, and evaluate a shell script (multiple-choice, fill-in-the-blank).

  6. Filters: Use Unix filters to answer some questions (coding on the computer).

All portions of the exam will take place online. Parts 1 through 5 will be an online quiz while Part 6 will require submitting code to your assignments repository.

Representative, but not Exhaustive

This check list is meant to be representative, rather than exhaustive (ie. there may be questions that show up on the exam that are not shown below).

Introduction

Concepts

Commands

  1. git

    Version control system for managing our files.

Sample Questions

  1. Which environmental variable does the shell search to locate an executable?

    • APPS
    • HOME
    • PATH
    • PROGRAMS

  2. How would you create a new checklist01 branch off the latest master branch?

Files

Concepts

Commands

  1. ls

    List the contents of a directory (long, human-readable, sorted)

  2. chmod

    Set permissions using octal and symbolic arguments.

  3. stat

    View the inode information for a file.

  4. du

    View the total disk usage for a file or directory.

  5. ln

    Create hard and soft links.

  6. find

    Search directory for files by name and type.

Sample Questions

  1. Which of the following commands makes a file executable?

    • chmod +x file
    • stat file
    • make file
    • test -x file

  2. Which of the following commands shows the meta-data of a file?

    • ls -l file
    • stat file
    • du file
    • find file

Process

Concepts

Commands

  1. ps

    List the processes for the current user and for the whole system.

  2. top

    Interactively view and manage processes.

  3. kill

    Signal a process by PID.

  4. time

    Measure how long it takes a process to execute.

  5. pkill

    Signal a process by name.

Sample Questions

  1. Which of the following commands forcefully terminates a process?

    • kill PID
    • kill -9 PID
    • sudo kill PID
    • kill -KILL PID

  2. Suppose we were running cat. How would we signal to the program that we are done inputting text?

    • Control-Z
    • Control-I
    • Control-D
    • Control-C

I/O Redirection

Concepts

Commands

  1. tee

    Redirect stdin to both stdout and a file.

  2. write

    Write to another users terminal.

Sample Questions

  1. Which of the following pipelines counts all the "Permission denied" errors encountered when recursively searching file names under the "/etc" directory?

    • find /etc > /dev/null | wc -l
    • find /etc 2>&1 > /dev/null | wc -l
    • find /etc 2> /dev/null | wc -l
    • find /etc > /dev/null 2>&1 | wc -l

  2. Which of the following appends the standard output of a program to a file?

    • program > output
    • program 2> output
    • program >> output
    • program &> output

Networking

Concepts

Commands

  1. ip / ifconfig

    List the IP addresses of the current machine.

  2. nmap

    Scan remote machine for open ports.

  3. nc

    General purpose tools to communicate with TCP-based network services.

  4. curl

    Communicate using HTTP (ie. download files from the web).

  5. ping

    Measure the latency from host to remote machine.

Sample Questions

  1. Which of the following commands can be used to measure bandwidth?

    • wget URL
    • ping URL
    • nmap URL
    • curl URL

  2. Which of the following statements are true (select all that apply)?

    • Every domain name translates to at least one IP address.
    • Every IP address is publically accessible.
    • Every IP address maps to exactly one domain name.
    • Every device has an IP address of 127.0.0.1.

Shell Scripting

Concepts

  1. What is a shell script? What is a she-bang and why do we need it (or what does it do)?

    You should understand how a shell script is interpreted and the impact the she-bang has on this interpretation. You should also know how to execute a shell script.

  2. You should know the basics of the shell programming language:

    1. variables

    2. capturing STDOUT

    3. if statement

    4. case statement

    5. for loop

    6. while loop

    7. function

  3. How do we parse command line arguments in a shell script?

Commands

  1. sh

    Bourne shell interpreter.

  2. test

    Perform checks on file types and values.

  3. tar

    Extract or compress tarballs.

  4. seq

Sample Questions

Debugging

The following scripts contain errors. Identify and correct all the bugs.

  1. This script checks each file passed via command line arguments and reports if the file is readable.

    for $file in '$@'; do
        [-r $file] | echo file is readable!
    done
    
  2. This script checks each file passed via command line arguments and reports if the file is readable.

    is_readable() {
        test -r $@
    }
    
    while (-n "$#"); do
        is_readable("$@") | echo $@ is readable!
    
    done
    

Filters

Concepts

  1. What are the three tenets of the Unix Philosophy?

  2. What are regular expressions?

    You will need to know the basic metacharacters such as

    • .
    • *
    • []
    • [^]
    • ^
    • $
    • ()
    • |
    • \n
    • {m, n}

    You will also need to be familiar with the basic character classes and their character set equivalents such as:

    • [:alpha:] = [a-zA-Z]
    • [:lower:] = [a-z]
    • [:upper:] = [A-Z]
    • [:space:] = [ \t\r\n\v\f]
    • [:digit:] = [0-9]

  3. What are filters?

    You should be familiar with the general idea of a filter and know how to use specific tools for certain tasks.

Commands

  1. cut

    Extract fields or characters.

  2. sort

    Order text.

  3. uniq

    Remove duplicates.

  4. tr

    Translate from one set of characters to another.

  5. grep

    Search based on pattern.

  6. sed

    Search and replace or extract text based on regular expressions.

  7. head

    Display first few lines of input.

  8. tail

    Display last few lines of input.

Sample Questions

Given the file tmnt.txt, which contains:

Leonardo:blue:katana
Donatello:purple:bo
Raphael:red:sai
Michelangelo:orange:nunchucks

Given the tmnt.txt file above, write Unix pipelines that perform the following tasks: