"

Level 1 Linux Exercises

Level 1 Background Information

Linux Quick Reference

  1. mkdir – to organize files and directories. This will make a new directory:
    mkdir CS_Programs
  2. cd – change into another directory:
    1. To change into a specific directory: cd  CS_Programs
    2. To change into a directory using a wild card: cd  CS*
    3. To change back to the directory above: cd  ..
    4. To change to the root directory (regardless): cd
  3. ls – list directory contents:
    1. To list the contents of the current directory: ls
    2. To list the contents of specific files (e.g., that start with a capital P): ls  P*
    3. To list the contents of a specific directory: ls  CS_Programs
    4. To list the contents of directories using a wild card: ls  CS*
    5. Add flags to get more detailed displayed: ls -l /etc
    6. Use the wildcard (*) to list all of the .cpp files in the current directory: ls  *.cpp
  4. cat – to display the contents of a file: cat test1.cpp
  5. pwd – to determine your current path and directory name : pwd
  6. cp – copy a file or directory:
    1. For example: cp source dest if you want to copy a directory use the -R option for recursive. The forward slash (in front of the path) means that we are working from the root directory: cp  -R  ./source   ./dest
    2. The source and destinations may be complete paths or a path from the current directory; the following will copy the entire CS_Programs directory and all of its files into the CS_Copy directory:
      mkdir CS_Copy
      cp  -R  CS_Programs   CS_Copy
  7. mv – move a file or directory. You could think of this as a rename but it can also move a file to another directory! Make sure to pay close attention to the order of the arguments. The first argument (source) is the file or directory that you want to copy from and the second argument (dest) is the file that you want to copy to (e.g., the file to be created). Keep in mind that a move does not leave the original (unlike copy) so use it with great caution!
    1. Syntax: mv source dest
    2. Move a file: mv program1.cpp  new_name.cpp
    3. Rename a directory: mv CS_Programs  new_directory_name

 

License

CS Linux & Vim Manual Copyright © by Karla Fant. All Rights Reserved.

Share This Book