Difference between revisions of "Introduction to Unix/Linux"
From WLCS
Line 60: | Line 60: | ||
*# For each of the commands below: | *# For each of the commands below: | ||
*#* Describe the command and what it does (mv - moves a files or directory ) | *#* Describe the command and what it does (mv - moves a files or directory ) | ||
− | *#* | + | *#* Give an example of using each (mv test.txt programs/) |
*#** ls | *#** ls | ||
*#** cd | *#** cd |
Revision as of 12:11, 15 September 2010
Introduction
Before we get into programming, 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/Linux 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
Procedures
- As a class, we will perform the following procedures
- Open a command-line terminal: Applications -> Accessories -> Terminal
- List the files and directories in your current location: ls
- Create a directory named programs: mkdir programs
- Change directory and go into the programs directory: cd programs
- Create directories named gvr, python, deleteMeLater
- mkdir gvr
- mkdir python
- mkdir deleteMeLater
- List the files and directories: ls
- Travel back UP the directory tree (go back up): cd ..
- List the files and directories: ls
- Create a text file named test.txt: nano test.txt
- Add some text to the file: blah blah blah
- Save the file before you leave nano: Ctrl-O
- Exit nano: Ctrl-X
- Display the contents of the test.txt file: cat test.txt
- Copy the test.txt file to a new filed named testCopy.txt: cp test.txt testCopy.txt
- List the files to see if copying worked: ls
- Remove the test.txt file: rm test.txt
- Go into the programs directory: cd programs
- Remove / delete the deleteMeLater directory: rmdir deleteMeLater
- Go back up in the directory tree
- If you list the files, what are you going to see?
- Go back up in the directory tree
- If you list the files, what are you going to see?
- Move the testCopy.txt file into the programs directory: mv testCopy.txt programs/
- 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
- For each of the commands below:
- Describe the command and what it does (mv - moves a files or directory )
- Give an example of using each (mv test.txt programs/)
- ls
- cd
- cd ..
- mkdir
- rmdir
- cp
- mv
- rm
- cat
Evaluation (10 pts)
- The evaluation for this lesson will consist of a performance exercise:
- Create a directory named sports in your home directory.
- Create subdirectories in the sports directory named baseball, football, basketball, and soccer.
- 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.
- 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
- If you complete the evaluation early, then you should visit the Unix Tutorial for Beginners and try to learn more commands:
- pwd
- man
- rm -rf
- Continue through the Unix Tutorial for Beginners to become a Unix expert!