Linux Exercise

The following exercises are designed to give you more practice with the Linux file system and commands. You can either log into the Linux system and do them (for practice and to know for sure what they do) or just do them as a pencil and paper exercise.

  1. When you first log into the Linux system you are in your home directory. There are three different ways to specify the pathname for your home directory.
    1. One is a single symbol. What is that symbol?
    2. One is the full pathname. What is the full pathname without using the symbol mentioned above?
    3. What is the other notation for your home directory?

  2. If jdoe is a user on the system, what indicates his/her home directory?

  3. Linux has a directory named home. What does it contain and what is the full pathname of it?

  4. What is the shortest command that takes you to your home directory no matter where you are in the system?

  5. Suppose you are in your home directory and you execute the following sequence of shell commands:
            mkdir play
            cd play
            mkdir what
            mkdir where
            cp ~/cs120/labs/lab1/ what
            cp ~/cs120/labs/lab1/ .
    Where are you after you have entered those commands (exactly those, no more)? How could you find out where you are if you don't know?

  6. Draw a tree showing the structure of your directory after doing the above commands (assume you have the cs120 and lab directories we have set up in lab plus things created by the above commands).

  7. As you know, the command to move around the directory structure (to change directories) is cd. To use the cd command you must also specify where you want to go (and the "where" must be understandable to the shell - how you specify it depends on where you are). Suppose you are in the play directory created above. Where do each of the following commands take you from play? (Note: some of these commands are errors!)
    1. cd where
    2. cd /cs120/labs
    3. cd labs
    4. cd
    5. cd ../cs120/labs/lab1
    6. cd ../../..

  8. Suppose you are currently in the labs subdirectory of your cs120 directory and you want to copy UnixQuestions (which is in your lab0 directory) to the directory named "where" created by the sequence of commands above. Give at least two different ways you can do that. For each way you give, state where you are after your command or sequence of commands.