Week 1¶

Useful UNIX commands:¶

  • pwd = print working directory (where am I now?)
  • ls = list (what's in this directory?)
    • ls -lah = list all files in human-readable form
  • cd (destination) = change directory to an absolute or relative destination
    • cd ~ = go to user's home directory
    • cd .. = move up one directory
    • ./ = 'here'
  • cp (file to be copied) (destination) = copy file to a destination
    • cp -r (directory to be copied) (destination) = copy directory to a destination
  • mkdir (name of new directory) = make a new directory inside your current directory
  • mv (file to be moved) (destination) = move file to new destination
    • mv -r (directory to be moved) (destination) = move directory to a destination
    • Renaming a file or directory: mv the file or directory to its current destination
  • rm (file to be removed) = delete a file
    • rm -r (directory to be removed) = delete a directory
    • THIS IS FOREVER, BE SURE YOU WANT TO rm WHATEVER YOU ARE rm-ING!!
  • nano (filename) - opens nano text editor on the file specified. If file doesn't exist, nano will create it
    • Use shortcut commands listed at bottom of nano screen to save file or exit
  • * = wildcard, represents any number of any characters
    • *.txt = any file ending with .txt
    • abc* = any file that starts with abc
    • *7* = any file that has a seven somewhere in the middle
  • ? = represents any one character
    • file?.txt = any file that starts with "file", has one character of any type, and ends with ".txt"
  • wc = word count
    • wc -l = count number of lines
    • check out wc -h for all available options
  • grep = search a file for a patter
    • grep is very detailed, check out grep -h for usage
  • | = pipe, take the output of the last operation and use it as the input for the next operation
    • grep "lily" flowers.txt | wc -l = searches for occurrences of "lily" in the flowers.txt file and returns the number of lines