Introduction to Unix/Linux

From WLCS
Revision as of 23:35, 16 September 2008 by Admin (talk | contribs) (Protected "Introduction to Unix/Linux" [edit=sysop:move=sysop])
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

Before we get into programming proper, we need a few fundamental "survival skills" which we will use to control our environment. You will need to be able find your way around the UNIX Operating System.

Now let's begin!

Objectives

  • You will be able to:
    • open a command-line terminal
    • draw an example file tree structure
    • list the files and directories (folders) using the ls command
    • navigate through the file system using the cd command
    • create a directory / folder using the mkdir command
    • remove / delete a directory using the rmdir command
    • create a text file using the nano program
    • copy a file using the cp command
    • move a file or directory using the mv command
    • remove / delete a file using the rm command
    • display the contents of a file using the cat command

Resources

Unix Tutorial for Beginners

Procedures

  • As a class, we will perform the following procedures
  1. Open a command-line terminal: Applications -> Accessories -> Terminal
  2. List the files and directories in your current location: ls
  3. Create a directory named programs: mkdir programs
  4. Change directory and go into the programs directory: cd programs
  5. Create directories named gvr, python, deleteMeLater
    1. mkdir gvr
    2. mkdir python
    3. mkdir deleteMeLater
  6. List the files and directories: ls
  7. Travel back UP the directory tree (go back up): cd ..
  8. List the files and directories: ls
  9. Create a text file named test.txt: nano test.txt
    1. Add some text to the file: blah blah blah
    2. Save the file before you leave nano: Ctrl-O
    3. Exit nano: Ctrl-X
  10. Display the contents of the test.txt file: cat test.txt
  11. Copy the test.txt file to a new filed named testCopy.txt: cp test.txt testCopy.txt
  12. Remove the test.txt file: rm test.txt
  13. Go into the programs directory: cd programs
  14. Remove / delete the deleteMeLater directory: rmdir deleteMeLater
  15. Go back up in the directory tree
  16. If you list the files, what are you going to see?
  17. Go back up in the directory tree
  18. If you list the files, what are you going to see?
  19. Move the testCopy.txt file into the programs directory: mv testCopy.txt programs/
  20. Display the contents of the testCopy.txt file: cat programs/testCopy.txt
  • Tab completion
    • Type the first several letters of a file or directory and then press tab
    • Example: cd pro<TAB>
  • Now that we have gone through several commands, you should create a cheatsheet for them. Open a new text document that describes the following commands and gives an example of using each:
    • ls
    • cd
    • cd ..
    • mkdir
    • rmdir
    • cp
    • mv
    • rm
    • cat

Evaluation (10 pts)

  • The evaluation for this lesson will consist of a performance exercise:
  1. Create a directory named sports in your home directory.
  2. Create subdirectories in the sports directory named baseball, football, basketball, and soccer.
  3. Create a file named stars.txt in the baseball directory. Add the names of three baseball stars, one per line, to this file. If you don't know the names of any baseball stars, just make up three names.
  4. Repeat the previous step in each of the other subdirectories of the sports directory.
  • Demo to Mr. Bui your new files and directories (5 pts)
  • Show Mr. Bui your cheat sheet (5 pts)

Challenge