Project 0: Linux Warm Up


This project is to help you getting familiar with Linux, which is, in fact, the operating system in the course title Operating System Labs. We will only cover two topics here, but we suggest that you play with it as much as you can. It is really fun and exciting. Although you will be stuck with this black annoying system at some point (almost surely), you can definitely learn something from this great software.


We first give you two simple tasks, and you will try to accomplish them with a few lines of shell scripts. Understanding some basic commands (cd, cp, ...) and concepts (redirection, pipe ...) is important. In the second part, you will practise with the C programming environment (gcc compiler, gdb debugger), which will be your best friends in the rest of the semester.


OSTEP Lab Tutorial

Program Specifications

Part 1

You need to write two shell scripts, both of them should be executable in a Linux shell.

The following is an example of output

bacman root -rwxr-xr-x
badblocks root -rwxr-xr-x
baobab root -rwxr-xr-x
base64 root -rwxr-xr-x
basename root -rwxr-xr-x
bash root -rwxr-xr-x
bashbug root -r-xr-xr-x
bayes.rb root -rwxr-xr-x
bbox root -rwxr-xr-x

Part 2

You need to compile/run a C program set_operation.c. The program contains several simple bugs, and you are going to detect and correct them using the gdb debugger.

Here are some details of the set_operation.c:

The program after being corrected should run as follows:

----Computing (A-B)union(B-A)----
----input the number of elements of A: 3
1-th element: 3
2-th element: 4
3-th element: 5
----input the number of elements of B: 2
1-th element: 1
2-th element: 4
---- elements of (A-B)union(B-A) ----
1-th element: 3
2-th element: 5
3-th element: 1


Part 1

When you need some details of a command, use man. Output some informations properly when scripts are running. For example, for the second script, show the number of the instances of the file when it is created.

Part 2

Hand In

General Advice

Try to use and get familiar with the shell commands first. Make good use of "man", "help" and "--help".

Start small, and get things working incrementally. For example, you can try to write some sub-functions in your script first, then test them before you combine them together. For debugging, you could build several test cases, and see why the running process of the program is different from your expectation.