Introducing the Shell


  • The shell gives you the ability to work more efficiently by using keyboard commands rather than a GUI.
  • Useful commands for navigating your file system include: ls, pwd, and cd.
  • Most commands take options (flags) which begin with a -.
  • Tab completion can reduce errors from mistyping and make work more efficient in the shell.

Navigating Files and Directories


  • The /, ~, and .. characters represent important navigational shortcuts.
  • Hidden files and directories start with . and can be viewed using ls -a.
  • Relative paths specify a location starting from the current location, while absolute paths specify a location from the root of the file system.

Working with Files and Directories


  • You can view file contents using less, cat, head or tail.
  • The commands cp, mv, and mkdir are useful for manipulating existing files and creating new directories.
  • You can view file permissions using ls -l and change permissions using chmod.
  • The history command and the up arrow on your keyboard can be used to repeat recently used commands.

Redirection


  • grep is a powerful search tool with many options for customization.
  • >, >>, and | are different ways of redirecting output.
  • command > file redirects a command’s output to a file.
  • command >> file redirects a command’s output to a file without overwriting the existing contents of the file.
  • command_1 | command_2 redirects the output of the first command as input to the second command.
  • for loops are used for iteration.
  • basename gets rid of repetitive parts of names.

Writing Scripts and Working with Data


  • Scripts are a collection of commands executed together.
  • Transferring information to and from virtual and local computers.

Project Organization


  • Spend the time to organize your file system when you start a new project. Your future self will thank you!
  • Always save a write-protected copy of your raw data.