• You are to work with a partner for this homework
1 Unix tutorial (40pts)
1. What happens if you give the following command when the fle named done
already exists? $ cp stuff done (3pts)
2. What command will move fles file1, file2 and file3 to directory dir?
(3pts)
3. What command would you use to make the current working directory your
home directory? (3pts)
4. What command identifes the working directory? (3pts)
5. What single command can you use to remove a directory called
/home/jporquet/old_stuff and all of its contents? We assume that this
directory might contain any number of sub-directories or fles. (5pts)
Hint: look into the manual page of ’rm’.
6. Based on the following output from $ ls -l: (10pts)
$ ls -l
total 68
-rwxr-x--- 1 jporquet users 19056 2017-05-21 18:22 fs_make
-rwxr-x--- 1 jporquet users 28536 2017-05-31 15:26 fs_ref
drwxr-x--- 2 jporquet users 4096 2017-05-24 20:28 libfs
-rw------- 1 jporquet users 1436 2017-05-22 13:44 Makefile
-rw------- 1 jporquet users 5676 2017-05-21 18:23 test_fs.c
1. Is fs_make a regular fle?
2. Is libfs a regular fle?
3. May members of the group ’users’ read the fle Makefile?
4. When was fle fs_ref last modifed?
5. What does the feld 1436 mean for fle Makefile
7. What command would you use to display the contents of fle myfile one
screen at a time? How would you scroll down one line without moving your
fngers from the home row? (4pts)
8. How would you display the frst three lines of fle myfile? (3pts)
9. After compiling your program, you run it in the terminal. Unfortunately,
there must be a bug because the process seems stuck and does not end.
What can you do to terminate the process and forcefully get back to the
shell prompt? (3pts)
10. What command displays the documentation for the diff utility? (3pts)
2 Vim tutorial (30pts)
For all the following questions, you have to fnd the (minimal) sequence of
keystrokes that performs the required action.
• Initially we start in normal mode, and we must end in normal mode as well
• You can use special keystrokes: (escape key), (Return key)
• Unless instructed, you don't have to save and/or quit as part of the
sequence
2.1 Challenges
For the challenges, you have to fnd the (minimal) sequence of keystrokes that
gets from the initial text to the result text.
• The position of cursor is on the red bold letter
• Stay away from the arrow keys, and use the proper shortcuts
1. Moving cursor (6pts)
Initial:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Result:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
2. Insertion/deletion (6pts)
Initial:
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
Result:
oeLrm ipsum dolor sit amet,
consectetur adipiscing elit,
3. Append/Open new line (6pts)
Initial:
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Result:
Hello!
Lorem ipsum dolor sit amet, consectetur adipiscing elit, latin
2.2 General questions
4. After spending several hours writing a long C fle, you realize that you
would like to change the name of one of your variables. The variable is
being referenced tons of times throughout your code, so it would waste too
much time to change all these references manually. Assuming the variable
name is ‘tmp’ and you would like to rename it into ‘time_elapsed’, what
is the sequence of keystrokes you should type? (6pts)
5. Assuming you are currently editing C fle main.c and you would like to
compile it into an executable without leaving vim. What is the sequence of
keystrokes you can type in order to make that happen? (6pts)
3 C 101 (30pts)
1. What is the exit status and by whom is it produced? Who receives it? What
is its purpose? (6pts)
2. Assuming a C fle ocean.c, what are the commands to: (6pts)
◦ compile it into an executable fle named eleven, while enabling all the
warnings and treating them as errors?
◦ run the resulting executable fle?
3. What are the three phases that compose all the programming assignments
for HW1? (6pts)
4. Assuming that variable k is of type int: (6pts)
◦ What does k contain after the assignment statement k = 3.14159?
◦ What does k contain after the assignment statement k = 2.71828?
5. Stylistically, which of the following identifers would be better choices for
names of constant macros? (Justify briefy) (6pts)
gravity G MAX_SPEED Sphere_Size