Introduction to the Command Line


Feel free to improvise over this outline by adding new sections, chapters etc

This book is an introduction to using the shell with a focus on empowering GNU/Linux newbies.  This page has an outline. The book itself is being written at:

It is meant to be fun and encourage the reader to play, so it is not organized in a formal manner (for instance, discussing all metacharacters in one place). Instead, features are introduced in the context of useful tasks. Rarely used features are not discussed.

The main topic is the GNU/Linux Bash shell, but useful features of the Korn shell and zsh may be introduced in advanced chapters. The C family of shells and non-Unix shells are beyond the scope of the book.

It assumes the reader is familiar with graphical interfaces, and refers to one or more free desktop environments where discussions of GUIs are necessary.

  1. Put yourself in command: why knowing the command line is useful
    1. Example: show a set of operations that require many menus and clicks to accomplish in a GUI (for instance, image manipulation) and then how to do the same things in a single command (for instance, using ImageMagick).
    2. The value of scripting
    3. Other places where command-line skills are useful
      1. Working over a network (when remote terminals or X redirection are unavailable or too slow)
      2. At jobs and cron jobs
      3. Invoking commands through GUI launchers
      4. Seeing what's going on (ps output, other system trouble-shooting)
  1. Getting started
    1. What do we mean by a "command"? 
    2. What ways can you enter commands?
      1. Opening a terminal window
      2. Alternative ways to run a command on various popular desktops
    3. Different shells
      1. This book focuses on Bash
      2. We tell you what's non-portable (doesn't work with older shells)
    4. Privileged (superuser) commands
  1. sudo
  2. su
  1. Beginning syntax: command-line options
  1. Moving around directories
    • Pathnames
      simple, absolute, and relative
    • The . and .. directories
    • cd, pushd, etc.
  2. Pathnames (syntax) 
  3. Using the history (through the readline facility)
    1. Emacs mode
    2. vi mode
  4. A few useful bits of syntax
  1. Enclosing strings in quotation marks
  2. Escaping special characters through quotation marks and backslashes 
  3. Continuing a command over multiple lines
  4. White space as separators (any amount is treated the same)
  1. Basic commands
  1. Commands people use every day
  1. pwd
  2. ls -al
  3. cd
  4. chown
  5. chmod
  6. more, less
  7. mv
  8. cp
  9. rm
  10. wc
  11. diff
  12. gzip, gunzip, gzcat
  13. rm, rmdir
  14. mkdir
  15. find
  16. grep
  17. passwd
  18. kill
  19. telnet, ssh
  20. ftp
  21. apt-get, yum
  22. echo
  23. setenv, unset
  24. du -h
  25. lynx
  26. ln
  1. Permissions
    1. Viewing through ls
    2. Setting through chmod
      1. +x syntax
      2. 777 octal syntax (a figure is useful to show bits
  2. Manipulating processes
    1. Interrupting (CTRL-C)
    2. ps and kill
    3. Processes and jobs (background)
  3. Redirection
    1. Using < and > and variations
    2. File descriptors (standard input, output, and error)
  1. Cheaper by the dozen: operating on lots of files in a single command
  1. Globbing
  2. The find command 
  3. The "for" control construct
  1. All that typing is too much work
    1. Command and filename completion 
    2. Using the history, part 2 (through the ! and ^ facilities) 
    3. Aliases
    4. Functions
  1. More command-line mastery
    1. Piping commands 
    2. Taking advantage of the exit status
      1. The if/then construct
      2. The && and || constructs
    3. Subcommands
      1. The $(command) syntax
      2. The `` backtick syntax
    4. Parameter substitution
    5. Multiple and remote sessions
      1. GNU Screen
      2. SSH
      3. Virtual terminals (GNU/Linux)
  2. Useful customizations
    1. Variables
      1. Syntax
      2.  Environment variables
    2. The search path
      1. Finding a command (which)
      2. Multiple locations for commands, and using symbolic links
    3. Setting prompts
    4. Localization
      1. How the computer generally chooses locale
      2. How to explicitly control locale
      3. Effects of locale on Bash
      4. Effects of locale on common programs and operations
  1. Before scripting: learning a text editor (keep it short; use screenshots)
  1. gedit
  2. Kedit
  3. nano
  4. vi 
  5. Emacs
  6. Saving useful changes: .bashrc and other startup/shutdown files 
  7. The value of portability (lowest common denominator commands)
  1. Scripting (mostly an example-based or recipe-based chapter, because all the important constructs have been introduced)
  1. Making scripts executable
  2. More control constructs (while, until, case, etc.) 
  3. Argument lists
  4. How to keep the script maintainable
    1. Use variables
    2. Know where you begin (which directory, whether you're superuser) 
    3. Look before you leap (does a file you want to read exist, etc.) 
    4. Check error status 
    5. Error messages
  5. Here documents (the << syntax)
  6. Sourcing other files
  7. Restricting access
  1. Using permissions
  2. The suid bit
  1. Other scripting languages
  1. Why use something else besides a shell
  2. Python
  3. Ruby 
  4. Perl 
  5. Awk