Carrie's Basic Unix Tutorial --- Under Development!


Commands covered: mkdir, ls, cd, cp, mv
Other material covered: tab completion


  1. Log into your borg account.

  2. Confirm that you are in your home directory.
     pwd 
    pwd stands for print working directory, and should show something like /users/grad/gates.

  3. Create a directory called "tutorial" for this tutorial.
     mkdir tutorial 
    mkdir stands for make directory.

  4. Change into your newly created directory.
     cd tutorial 
    cd stands for change directory.

  5. Copy the file "this_is_a_tutorial_file" from /users/grad/gates/public_html/tutorials into your current directory
     cp /users/grad/gates/public_html/tutorials/this_is_a_tutorial_file . 
    cp stands for copy. To "move" the original file to a new location, rather than copying it, use "mv". If you try to mv the above file, you will get a permission denied because you do not own the file (more on permissions later!) Also, note that the "." here means the current directory. To copy that file to the parent directory (in this case, your home directory), use "..".

    Shortcuts:

    • Type ~gates instead of /users/grad/gates.
       cp ~gates/public_html/tutorials/this_is_a_tutorial_file . 
      This works because the shell interprets the ~ as meaning check the password file for the path to the home directory of the username occuring after the ~.
    • Type ~gates/public_html/tutorials/this and then hit the tab key. Your shell (bash) has a feature called tab completion, where hitting the tab keys tells the shell to try to finish the directory or file name. If there was another file in that directory that was called this_is_a_teaching_file, then hitting the tab key after typing "this" would result in completing the filename until it hits a difference. That is, the result would be "this_is_a_t", followed by a beep to indicate that it can't complete the filename. Hitting the tab key a second time tells the shell to list all the files that start with "this_is_a_t".

  6. Check to see that your current directory now contains the file.
     ls 
    ls stands for LiSt files.

  7. Rename this_is_a_tutorial_file to tut_file. (Remember to use tab completion!)
     mv this_is_a_tutorial_file tut_file 
    mv stands for MoVe file. You can use this command to move/rename directories as well as files. Unix treats directories as essentially a special type of file.

  8. Look at the contents of tut_file.
     cat tut_file 
    cat is short for concatenate. You can use this command to display multiple files by listing more files after the command, e.g.
     cat file1 file2 file3 
    There are many other ways to view a file. Rather than have the whole file scroll by, it can be viewed page by page using "more" or "less". The command "less" is just like "more" except that it has more functionality. Try using less now (to get out of less, hit q for quit):
     less tut_file 

To be added: grep tr sort uniq pipes redirection head tail man top w permissions finger and things like gcc a5.c | less 2>&1