Unix Intro 2

Unix Intro 2

Unix Intro 2 Directory Commands mkdir DIR_NAME Make/create directory DIR_NAME. rmdir DIR_NAME Remove/delete directory DIR_NAME. Deleting Files To remove a file use the rm command. The rm command will be used below. A deleted file cannot be un-deleted, there is no Trash that it is put into. Creating a Directory The mkdir command is used to create a new directory. Type the commands: ls -l # List your files mkdir New_Dir # Create a directory named New_Dir in the current directory ls -l # New_Dir exists now Since you haven't changed directories you are in your home directory. The mkdir command created a directory named New_Dir in your home directory. File and directory names should not include any spaces. Changing the Current Directory - 2 Now we want to work in the New_Dir directory. We need to change our current directory to the New_Dir directory. Type the commands: pwd # Show the directory you are currently "in" cd New_Dir # "Go" into New_Dir pwd For demonstration purposes we would like to create a file in this subdirectory. Type the commands: ls -l # List your files, there are none touch anewfile # Create an empty file called anewfile ls -l Changing the Current Directory - 2, continued In each directory there are always two special files. 1. One has the name "." (a single period) that denotes the current directory. 2. The other has the name ".." (two periods immediately after each other) that denotes the parent directory. Now we want to move out of the subdirectory New_Dir and back to our home directory. Type the commands: pwd cd .. # ".." denotes the parent of the current directory, the directory the current directory is in pwd Also, you can move directly to your home directory, no matter where you are at, by using the cd command by itself. Files Data is stored on computer systems in files. Much of the work that we do involves manipulating files. There are various commands to list, rename, and otherwise access files. Redirecting Output Output from a command goes to the terminal window by default. It is possible to have the output from a command go into a file instead. Type the commands: ls # List files, output to terminal window ls > out.txt # List files, output to file out.txt clear # Clear the window cat out.txt # Show what's in the file By default error messages don't go into a file. By using >& all output will go into the file. Type the commands: rm out.txt # Delete the file ls out.txt # out.txt was just deleted, error message from ls command ls out.txt > err.txt # Error message from ls command not sent to file clear # Clear the window cat err.txt # Show what's in the file, empty file ls out.txt >& err.txt # Error message from ls command sent to file clear # Clear the window cat err.txt # Show what's in the file, error message rm err.txt # Delete file Main -- Notes -- Unix_Intro_2 -- Slides.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us