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, andcd. - 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 usingls -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,headortail. - The commands
cp,mv, andmkdirare useful for manipulating existing files and creating new directories. - You can view file permissions using
ls -land change permissions usingchmod. - The
historycommand and the up arrow on your keyboard can be used to repeat recently used commands.
Redirection
-
grepis a powerful search tool with many options for customization. -
>,>>, and|are different ways of redirecting output. -
command > fileredirects a command’s output to a file. -
command >> fileredirects a command’s output to a file without overwriting the existing contents of the file. -
command_1 | command_2redirects the output of the first command as input to the second command. -
forloops are used for iteration. -
basenamegets 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.