KOI: Lab Exercise 0

This exercise is intended as an introduction to Linux for beginners. If you already feel comfortable with Linux you can skip it.

Read this first, at least quickly

Questions to Answer and Things to Do

  1. Log in.
  2. If you don't already have a shell window on your screen, open one. Use this shell window to do all the following!
  3. Which files and sub-directories does your home directory contain?
  4. Use the man command to look at the content of the manual page for the command ls. What does the flag -a do? Was your answer to the previos question entirely correct?
  5. Create a sub-directory called lab-0 in your home directory.
  6. Use cd to go to that directory, and then write a small C program in a source file called Hello.c. If you wish, you can use this program:
    #include <stdio.h>
    int main(void) {
      printf("Hello, world!\n");
      return 0;
    Use gedit to write the program.
  7. Use mv to change the name of the source file from Hello.c to hello.c. We almost always use entirely lower-case letter for file names in Unix.
  8. Compile the program with the C compiler gcc. Make sure that the executable file is called hello.
  9. Run the program.
  10. Make some modifications to the source in hello.c. Use emacs to edit the program!
  11. Type make hello. What happens?
  12. Type make hello again. What happens?
  13. Make some modifications to the source in hello.c, that will cause the compilation to fail. Try to compile the program, just to see how the error messages look.
  14. When editing the program in Emacs, you can use the compile command to compile your program. Type ESC x c o m p i l e RETURN, edit the command to use (for example to make hello), and press RETURN again. Emacs will open another buffer with the error messages. Position the cursor on an error message (for example by clicking with the mouse) and press RETURN. Emacs will go to the line in the program with the error.
  15. If you have time: Write a Makefile for the hello program.
  16. Use cp with the flag -r to make a copy of the entire sub-directory lab-0. The copy should be called lab-0-copy.
  17. Remove all the files in lab-0-copy.
  18. Remove the directory lab-0-copy.


You don't have to write a report or present anyting from this exercise, but if you have any questions or comments, please discuss them with the teaching assistant.

Thomas Padron-McCarthy (thomas.padron-mccarthy@oru.se) September 6, 2014