Content inventory first edition
Content Inventory of Introduction to the Command Line
Contents
Table of Contents: Sections and Chapter Headings
Introduction
- 1. Introduction
- 2. About this Manual
Basics
- 3. Getting Started
- 4. Beginning Syntax
- 5. Moving Around
Commands
- 6. Basic Commands
- 7. Standard Files
- 8. Cut Down on Typing
- 9. Superusers
- 10. Redirection
Advanced-ish
- 11. Multiple Files
- 12. Searching for Files
- 13. Piping
- 14. Processes
- 15. File Structure
- 16. Command History
Advanced
- 17. Permissions
- 18. Interactive Editing
- 19. Checking Exit
- 20. Sub Commands
- 21. Moving Again
- 22. Customization
- 23. Parameter Substitution
- 24. GNU Screen
- 25. SSH
- 26. Git
- 27. Installing Software
- 28. Making Your Own Interpreter
Text Editors
- 29. Text Editors [removed vim, emacs, kedit, gedit]
- 30. Nano
Scripting
- 31. Scripting
- 32. Maintaining Scripts
- 33. Other Languages
- 34. Sed
- 35. Awk
- 36. Regular Expressions
Scripting Languages [removed perl, ruby, GNU Octave]
- 37. Python
Appendices
- 38. Glossary
- 39. Command Quick
- 40. Outline
- 41. Credits
Content Inventory (Formatted)
1. Introduction
- 1.1. Put Yourself in Command [comparison of GUI and command line for same task]
- 1.2. Advantages of Using Commands
- 1.2.1. Flexibility
- 1.2.2. Reliability
- 1.2.3. Speed
- 1.2.4. Experience [learning experience]
- 1.2.5. Fun
- 1.2.1. Flexibility
- 1.3. The Value of Scripting
- 1.4. Is my Computer Sick? [get hardware and software info from command line]
- 1.5. Spanning the Network [execute commands on remote computer using command line]
- 1.6. Even Graphical Programs are Commands [examining GUI program behavior via command line]
- Terms: command line, command line interface, command line program, commands, GNU/Linux, graphical user interface, program, scripting, script, text file
2. About this Manual [origin of book and ways to contribute]
- 3.1. Getting Started
$date
- 3.2. The Command Line Can do Much Better [beyond simple commands without options]
- 3.3. What Do We Mean By a Command? [command is executable file; mentions builtins]
- 3.4. Ways to Enter Commands
- 3.5. Finding a Terminal
- 3.6. Running an Individual Command
- 3.7. How We Show Commands and Output in This Book
- Terms: shell, terminal, desktop environment
- Commmands: date
- 4.1. Arguments [examples of args using echo]
$echo foo
- 4.2. Options [examples of options using date]
$date --utc
- 4.3. Repeating and editing commands [keyboard up arrow for previous commands (no mention of history); right, left arrow to edit]
- Terms: argument, white space, quoting, option
- Commands: echo, date
5. Moving Around [navigating file system]
- 5.1. Absolute and relative paths
$pwd
$cd
- 5.2. Good to be back home [introduces home directory; two ways to return to it]
$cd
$cd ~
- 5.3 The . and .. directories
- Terms: folders, directories, filesystem, root directory, absolute path, relative path, parent directory (..), current directory (.)
- Commands: pwd, cd
- 6.1. ls
$ls
$ls --color
- 6.2. man, info & apropos
$man ls
$info ls
-
$emacs -f info-standalone
[view info main menu in Emacs]
$apropos rename
-
$apropos -s 1 rename
[brief into to manual page sections]
- 6.3. mv
$mv oldname newname
$mv -i oldname newname
$mv one_file another_file a_third_file ~/stuff
- 6.4. mkdir
$mkdir ~/stuff
$rmdir ~/stuff
- 6.5. rm & rmdir
- 6.6. cat & less
- Terms: subdirectory, manual page, Emacs, globbing, recursive
- Commands: apropos, cat, cp, info, less, ls, man, mkdir, rmdir
7. Standard Files [section introduces stdin, stdout, stderr; introduces redirection operator > and >>) and pipe; file descriptors; exec]
- 7.1. More about redirection
$ls *.bak > listfile
$ls *.bak | more
$ls -lR / | tee > allMyFiles
- 7.2. Redirecting stderr
$ls /nosuchplace > /dev/null
$ls /nosuchplace 2>/tmp/errors
$ls *.bak > listfile 2>&1
- 7.3. Adding more descriptors
$exec 3>/tmp/thirdfile
$exec 4>/tmp/fourthfile
$echo drib >&3
$ echo drab >&4
$ echo another drib >&3
$ echo another drab >&4
$ exec 3>&-
$ exec 4>&-
- Terms: pipes, stdin, stdout, stderr, redirection, standard input, standard output, standard error, *, file descriptor, >&, |, >, >>
- Commands: ls, tee, exec
- 8.1. All That Typing... [short intro]
- 8.2. Autocompleting [autocompletion using tab]
- 8.3. Copy and Paste [copy and paste into command line using GUI and mouse]
- 8.4. History [using keyboard up, down arrow to navigate history]
- Terms: auto completion, history
9. Superusers
- 9.1. The Superuser (Root) [narrative intro to root, superuser]
- 9.2. The sudo Command [brief into to sudo and su]
$sudo rm -r /junk_directory
- Terms: superuser, root
- Commands: sudo, su
10. Redirection [redirection to /dev/null; background process; job control not mentioned prior]
- 10.1. Redirection
-
$ls > my-file-list
[introduces >> in narrative] -
$bigprogram > /dev/null
[brief intro to /dev/null] $mail joe < myfile.txt
$ogg123 *.ogg &
$ogg123 *.ogg >/dev/null 2>music_err &
-
- Terms: redirection, clobbering, background [process], /dev/null, >, >>, <
11. Multiple Files
- 11.1. Multiple Files [introductory text]
- 11.2. Globbing
- 11.2.1. The "*" Wildcard
-
$rm -- *
[text says: When you use just an asterisk ("*") with rm, and basically any other command, it is always a good idea to put an option terminator ("--") before the wildcard like this:]
-
- 11.2.2. The "?" Wildcard
- 11.2.3. The "[ ]" Wildcards
- 11.2.4. Brace Expansion [first mention of bash]
- 11.2.1. The "*" Wildcard
- 11.3. Globbing When No File Matches
- 11.4. Disabling A Wildcard
- Terms: globbing, wildcards (?, *), anchors (^), ranges ([]), brace expansion, brace range {1..10}, escape (\), string, shell, hidden files, option terminator (--)
- 12.1. Wildcards with Find
$find . -name 'some*' -print
- 12.2. Trimming The Search Path
$find . -maxdepth 1 -name 'some*' -print
- 12.3. Using Criteria
$find ~ -mtime -3 -print
- 12.4. Using Find To Run a Command on Multiple Files [introduces exec option to find]
-
$find directory_to_backup -mtime +30 -size +500k -print \
-exec rm {} \;
$find . -name 'file*' -exec cp {} {}.backup \;
-
- Commands: find
13. Piping [introduces cat, cut, sort, uniq, and grep to illustrate the use of pipes]
- 13.1 Piping Hot Commands [illustrating use of pipes]
$cat books
$sort books
$cut -d: -f1 books
$sort books | cut -d: -f1
$sort books | cut -d: -f2
$cut -d: -f2 books | sort
$cut -d: -f1 books | sort | grep "John"
$cut -d: -f1 books | sort | grep ", John"
$cut -d: -f1 books | sort | grep ", John" | uniq -c
$cut -d: -f1 books | sort | grep ", John" | uniq -c | sort -nr
- Topics: pipes, delimiters
- Commands: cat, sort, cut, grep, uniq
14. Processes
- 14.1. Processes [briefly introduces concept of a process]
- 14.2. Interrupting (Ctrl-C) [introduces SIGINT as raised on CTRL-C; first mention of kernel]
- 14.3. ps and kill [introduces top; mentions tty]
$ps
$tty
$ps -e
-
$kill 3941
[doesn't explain where pid in example comes from; mentions kill and option 9, introduces SIGKILL, and $kill -s SIGKILL (pid)]
- 14.4. Processes and jobs (background) [starting process in background with &, introduces fg, bg, and Ctrl-Z, and jobs]
$firefox &
$fg 3694
$fg %1
$jobs
- Topics: processes, binary, executable, signals, SIGINT, foreground [process], background [process], process id (PID), terminal, tty, terminating a process, jobs
job number,
- Commands: ps, top, tty, kill, fg, bg
15. File Structure
- 15.1. Files and Directories [introduces GNU/Linux directory structure; introduces concept of hidden file (~/.sugar/default/logs), suggests referring to heir man page]
- Terms: root directory
- Commands: man
16. Command History
- 16.1. Command History Shortcuts [brief first mention of cron; reiterates keyboard arrow up, down to navigate history]
- 16.2. Recalling a command by a string [introduces !, !command:p, !!]
$!mv
$!mv:p
-
$!?log?
[Rhockens: I can't figure out how this works] -
$sudo !!
[after mentioning !! in text]
- 16.3. Recalling a command by number
$history
$!504
$!-4
- 16.4. Repeating arguments [introduces !*, !^, and !$, :number, and :number range]
- [code samples below in pairs showing original command and command using recall operator]
$emasc /home/fred/mywork.java /tmp/testme.java # FAILS
$emacs !* # fixed command name and recalled all arguments with !*
$emacs /home/fred/mywork.java /tmp/testme.java
$svn commit !^ # equivalent to: svn commit /home/fred/mywork.java
$mv /home/fred/downloads/sample_screen_config /home/fred/.screenrc
$emacs !$ # equivalent to: emacs /home/fred/.screenrc
$sudo cp /etc/apache2/sites-available/siteconfig /home/fred/siteconfig.bak
$echo !^ !!:2 # equivalent to echo cp /etc/apache2/sites-available/siteconfig
- 16.5. Editing Arguments [introduces editing recalled arguments with s/foo/bar]
$wc file1
$rm !$:s/1/2/ [expands to "rm file2"]
$wc file1
-
$^1^2
[Expands to "wc file2"; RH: Check on Arch]
- 16.6. Searching through the Command History [Ctrl-R for "reverse-i-search"]
- 16.7. Sharing Bash History [update ~/.bashrc; hidden files and text editing have not yet been introduced; don't believe bash has been formally introduced]
shopt -s histappend
PROMPT_COMMAND='history -a'
- Terms: command history, bang operator, bash shell, .bashrc
- Commands: !, mv, log, sudo, history, !*, !^, !$, emacs, svn, cp, wc, rm
17. Permissions
- 17.1. What can I do? What can others do? [introduces files types; r, w, x permissions; users and groups; whoami; root]
- 17.2. Setting through chmod [introduces two ways to change permissions]
$chmod u=rw,g=,o= motd
$chmod 0660 issue
18. Interactive Editing [introduces concept of key bindings; shows how to set vim or emacs; detailed discussion of emacs keybindings; suggests exploring vim on own; prior to discussion of vim in book]
19. Checking Exit
- 19.1. Exit Status [introduces exit status; 0 success; $?]
$echo $?
- 19.2. if/then [introduces compound command]
- 19.3. && and ||
- 19.4. What does an exit status mean?
20. Sub Commands
- 20.1. Command Substitution [introduces commmand substitution; breifly introduces adding alias to .bashrc; hidden files, text editing not yet introduced]
$grep `date +%b` apache_error_log
.bashrc: alias monthlog="grep `date +%b` apache_error_log"
$grep $(date +%b) apache_error_log
21. Moving Again [introduces directory stack; dirs; pushd dir; pushd; pushd +/- number; popd; illustrates state of state after various example commands]
22. Customization
- 22.1. Useful customizations [intro text]
- 22.2. Variables [assigning, unassigning variables]
$p=/home/jsmith/projects/foo/confoobulator
$cd $p
$VAR=""
$unset VAR
- 22.2. Variables [assigning, unassigning variables]
- 22.3. Ordinary Variables and Environment Variables
$export p
- 22.4. Shell Variables [describes several variables; SHELL, USER, PATH, etc.]
$echo $HOME
$env
- 22.5. Controlling Variable Expansion
$curr=myfile
$rm $curr1.jpeg # doesn't work
$rm ${curr}1.jpeg # works
- 22.6. The Search Path [brief into to search path; introduction of which]
- 22.7. Configuration Files [introduction to hidden files; .bashrc; reference to text editor chapter]
- 23.1. Parameter Substitution
$curr=myfile
$rm ${curr}.jpeg
$rm ${curr/file/picture}.jpeg # to change file to picture and rm mypicture.jpg
- 23.2. Playing Safe With Variables That Don't Exist [introduces :- and :=]
$cat "${VARIABLE_FILE_NAME:-/home/user/file}"
$cat "${VARIABLE_FILE_NAME:=/home/user/file}"
- 23.3. Cutting Corners With Variable Expansion
$export ALT_LS='--color=always -b -h --filetype'
$ls $ALT_LS
24. GNU Screen [introduces screen and key combinations for: splitting, copy and paste, detaching, quitting]
25. SSH [intro to ssh, scp, rsync; discourages telnet; detached remote session using screen]
- 25.1. SSH
$ssh othermachine.domain.org
$ssh -l remoteusername othermachine.domain.org
$ssh remoteusername@othermachine.domain.org
$ssh remoteusername@othermachine.domain.org 'mkdir /home/myname/newdir'
- 25.2. scp: file copying
$scp myprog.py me@othermachine.domain.org:stuff
$scp me@othermachine.domain.org:docs/interview.txt yesterday-interview.txt
$scp user1@host1:file1 user2@host2:otherdir
$scp -r user1@host1:dir1 user2@host2:dir2
- 25.3. rsync: automated bulk transfers and backups
$rsync -e ssh -a /home/myname/docs me@quantum.example.edu:backup/
- 25.4. Making life easier when you use SSH often [editing .ssh/config]
26. Git [list of basic git commands: clone, commit, revert; chapter appears incomplete]
Didn't realize that this chapter wasn't in the first edition Rhockens (talk) 08:33, 2 June 2019 (EDT)]
27. Installing Software [basic commands for apt-get and yum; brief overview of compiling from source]
- 27.1. Dependencies [introduction to topic]
- 27.2. Unpack the archive
$tar zxvf packagename.tar.gz
- 27.3. Run the configure script
$./configure
$./configure --prefix ~/bin/myprogs
- 27.4. Compile the software
$make
$make -j3
- 27.5. Install the software
$sudo make install
28. Making Your Own Interpreter [source code for bdc; compiling; usage]
29. Text Editors [including nano; omitting vim, emacs, kedit, gedit]
- 29.1. Text Editors [intro]
- 29.1.1. Word Processing vs Text Editing
- 29.1.2. Why do you need a text editor?
- 29.1.3. Why are most text editors command-line programs?
- 29.1.1. Word Processing vs Text Editing
- 29.2. Setting a default text editor
$export EDITOR=emacs
30. Nano [brief intro; basic use; start, save, exit]
31. Scripting
- 31.1. Scripting [intro; sample script]
- 31.2. Making scripts executable
$chmod +x make_thumbnails.sh
$./make_thumbnails.sh
$bash make_thumbnails.sh
- 31.3. More Control [examples of if, while, etc.]
- 31.3.1. if
- 31.3.2. while (and until)
- 31.3.3. case
- 31.3.4. for
- 31.3.5. parallel
- 31.3.1. if
32. Maintaining Scripts [guidelines for maintainable, robust scripts; e.g., "Use descriptive names for your scripts"]
33. Other Languages [introduction; introduces awk, sed, python; other languages omitted]
34. Sed
- 34.1. The Sed Text Processor
$wc -c * | sort -n | sed ...
- 34.2. Basic Syntax and Substitution
$sed "s/foo/bar/g" inputfile > outputfile
- 34.3. Sed Expressions Explained [introduces $, ^, *, []]
- 34.4. Deletion
$sed "/^$/d" inputfile > outputfile
- 34.5. Controlling Printing
$sed -n "s/Mrs\./Ms/p" testfile
- 34.6. Multiple Patterns
$echo Gnus eat grass | sed -e "s/Gnus/Penguins/" -e "s/grass/fish/"
- 34.7. Controlling Edits With Patterns
$sed "/one/ s/number/1/" testfile > testchangedfile
- 34.8. Controlling Edits With Line Numbers
$sed "2,3 s/number/1/" < testfile > testchangedfile
- 34.9. Scripting SED commands
$sed -f sedcommands < inputfile > outputfile
35. Awk [basic intro to awk]
36. Regular Expressions [basic intro to regular expressions; operators, ranges, groups, anchoring, etc.]
37. Python [new chapter TK]
38. Glossary [update for second edition]
Glossary terms that don't appear in text: aptitude, ash, aspell, bug report, character set, findutils, fontconfig, intltool, kernel-utils, lsof, openssh, syntax highlighting [some glossary terms only appear in Command Quickie]
39. Command Quickie [to be revised for second edition]
Commands in order of presentation: ls, man, info apropos, pwd, cd, mkdir, rmdir, touch, rm, ln, cp, mv, whoami, passwd, ps, kill, chown, chmod, more, less, pg, cat, grep, df, echo, file, diff, wc, find, ftp, wget, tar, gzip, gunzip, zcat, bzip2, bunzip2, bzcat, lynx, mc, emacs, vi, nano, pico, pr, lpr, split
40. Outline [proposed outline for a future edition]
41. Credits
Content Inventory (Plain text)
Introduction 1. Introduction 2. About this Manual Basics 3. Getting Started 4. Beginning Syntax 5. Moving Around Commands 6. Basic Commands 7. Standard Files 8. Cut Down on Typing 9. Superusers 10. Redirection Advanced-ish 11. Multiple Files 12. Searching for Files 13. Piping 14. Processes 15. File Structure 16. Command History Advanced 17. Permissions 18. Interactive Editing 19. Checking Exit 20. Sub Commands 21. Moving Again 22. Customization 23. Parameter Substitution 24. GNU Screen 25. SSH 26. Git 27. Installing Software 28. Making Your Own Interpreter Text Editors 29. Text Editors [removed vim, emacs, kedit, gedit] 30. Nano Scripting 31. Scripting 32. Maintaining Scripts 33. Other Languages 34. Sed 35. Awk 36. Regular Expressions Scripting Languages [removed perl, ruby, GNU Octave]<br /> 37. Python Appendices 38. Glossary 39. Command Quick 40. Outline 41. Credits 1. Introduction 1.1. Put Yourself in Command [comparison of GUI and command line for same task] 1.2. Advantages of Using Commands 1.2.1. Flexibility 1.2.2. Reliability 1.2.3. Speed 1.2.4. Experience [learning experience] 1.2.5. Fun 1.3. The Value of Scripting 1.4. Is my Computer Sick? [info on running hardward and software from cli] 1.5. Spanning the Network [executing commands on remote computers using cli] 1.6. Even Graphical Programs are Commands [examing GUI program behavior via cl] Terms: command line, command line interface, command line program, commands, GNU/Linux,graphical user interface, program, scripting, script, text file 2. About this Manual [origin of book and ways to contribute] 3. Basics 3.1. Getting Started $date 3.2. The Command Line Can do Much Better [beyond simple commands without options] 3.3. What Do We Mean By a Command? [command is executable file; mentions builtins] 3.4. Ways to Enter Commands 3.5. Finding a Terminal 3.6. Running an Individual Command 3.7. How We Show Commands and Output in This Book Terms: shell, terminal, desktop environment, Commmands: date 4. Beginning Syntax 4.1. Arguments [examples of args using echo] $echo foo 4.2. Options [examples of options using date] $date --utc 4.3. Repeating and editing commands [keyboard up arrow for previous commands (no mention of history); right, left arrow to edit] Terms: argument, white space, quoting, option Commands: date, echo 5. Moving Around [navigating file system] 5.1. Absolute and relative paths $pwd $cd 5.2. Good to be back home [introduces home directory; two ways to return to it] $cd $cd ~ 5.3 The . and .. directories Terms: folders, directories, filesystem, root directory, absolute path, relative path, parent directory (..), current directory (.) Commands: cd, pwd 6. Basic Commands 6.1. ls $ls $ls --color 6.2. man, info & apropos $man ls $info ls $emacs -f info-standalone [view info main menu in Emacs] $apropos rename $apropos -s 1 rename [brief into to manual page sections] 6.3. mv $mv oldname newname $mv -i oldname newname $mv one_file another_file a_third_file ~/stuff 6.4. mkdir $mkdir ~/stuff $rmdir ~/stuff 6.5. rm & rmdir 6.6. cat & less Terms: subdirectory, manual page, Emacs, globbing, recursive Commands: apropos, cat, cp, info, less, ls, man, mkdir, rmdir 7. Standard Files [section introduces stdin, stdout, stderr; introduces redirection operator > (but not >>) and pipe; file descriptors; exec] 7.1. More about redirection $ls *.bak > listfile $ls *.bak | more $ls -lR / | tee > allMyFiles 7.1. Redirecting stderr $ls /nosuchplace > /dev/null $ls /nosuchplace 2>/tmp/errors $ls *.bak > listfile 2>&1 7.2. Adding more descriptors $exec 3>/tmp/thirdfile $ exec 4>/tmp/fourthfile $ echo drib >&3 $ echo drab >&4 $ echo another drib >&3 $ echo another drab >&4 $ exec 3>&- $ exec 4>&- Terms: pipes, stdin, stdout, stderr, redirection, standard input, standard ouputt, standard error, *, file descriptor, >&, |, >, >> Commands: ls, tee, exec 8. Cut Down on Typing 8.1. All That Typing... [short intro] 8.2. Autocompleting [autocompletion using tab] 8.3. Copy and Paste [copy and paste into command line using GUI and mouse] 8.4. History [using keyboard up and down arrow to access history] Terms: auto completion, history 9. Superusers 9.1. The Superuser (Root) [narrative intro to root/superuser] 9.2. The sudo Command [brief into to sudo and su] $sudo rm -r /junk_directory Terms: superuser, root, Commands: sudo, su 10. Redirection [introduces >>; redirection to /dev/null; background process; job control not mentioned prior] 10.1. Redirection $ls > my-file-list [introduces >> in narrative] $bigprogram > /dev/null [brief intro to /dev/null] $mail joe < myfile.txt $ogg123 *.ogg & $ogg123 *.ogg >/dev/null 2>music_err & Terms: redirection, clobbering, background [process], /dev/null, >, >>, < 11. Multiple Files 11.1. Multiple Files [introductory text] 11.2. Globbing 11.2.1. The "*" Wildcard $rm -- * 11.2.2. The "?" Wildcard 11.2.3. The "[ ]" Wildcards 11.2.4. Brace Expansion [first mention of bash] 11.3. Globbing When No File Matches 11.4. Disabling A Wildcard Terms: globbing, wildcards (?, *), anchors (^), ranges ([]), brace expansion, brace range {1..10}, escape (\), string, shell, hidden files, option terminator (--), Commands: rm, ls, 12. Searching for Files 12.1. Wildcards with Find $find . -name 'some*' -print 12.2. Trimming The Search Path $find . -maxdepth 1 -name 'some*' -print 12.3. Using Criteria $find ~ -mtime -3 -print 12.4. Using Find To Run a Command on Multiple Files [introduces exec option to find] $find directory_to_backup -mtime +30 -size +500k -print \ -exec rm {} \; $find . -name 'file*' -exec cp {} {}.backup \; Topics: Commands: find 13. Piping [introduces cat, cut, sort, uniq, and grep to illustrate the use of pipes] 13.1 Piping Hot Commands $cat books $sort books $cut -d: -f1 books $sort books | cut -d: -f1 $sort books | cut -d: -f2 $cut -d: -f2 books | sort $cut -d: -f1 books | sort | grep "John" $cut -d: -f1 books | sort | grep ", John" $cut -d: -f1 books | sort | grep ", John" | uniq -c $cut -d: -f1 books | sort | grep ", John" | uniq -c | sort -nr Topics: pipes, delimiters Commands: cat, sort, cut, grep, uniq 14. Processes 14.1. Processes [breifly introduces concept of a process] 14.2. Interrupting (Ctrl-C) [introduces SIGINT as raised on CTRL-C; mentions kernel] 14.3. ps and kill [introduces top but doesn't demonstrate, mentions tty] $ps $tty $ps -e $kill 3941 [doesn't explain where pid in example comes from; mentions kill option 9, SIGKILL, and $kill -s SIGKILL (pid)] 14.4. Processes and jobs (background) [starting process in background with &, introduces fg, bg, and Ctrl-Z, and jobs] $firefox & $fg 3694 $fg %1 $jobs Topics: processes, binary, executable, singals, SIGINT, foreground [process], background [process], process id (PID), terminal, tty, terminating a process, jobsjob number, Commands: ps, top, tty, kill, fg, bg 15. File Structure 15.1. Files and Directories [introduces GNU/Linux directory structure, introduces concept of hidden file (~/.sugar/default/logs), suggests referring to heir man page] Terms: root directory Commands: man 16. Command History 16.1. Command History Shortcuts [breif first mention of cron; reiterates keyboard arrow up, down to navigate] 16.2. Recalling a command by a string [introduces !, !command:p, !!] $!mv $!mv:p $!?log? [RH: not sure what this is doing] $sudo !! [after mentioning !! in text] 16.3. Recalling a command by number $history $!504 $!-4 16.4. Repeating arguments [introduces !*, !^, and !$, :number, and :number range] [code samples are pairs showing original command and command using recall operator] $emasc /home/fred/mywork.java /tmp/testme.java # FAILS $emacs !* # FIXED COMMAND NAME, RECALLED ALL ARGUMENTS $emacs /home/fred/mywork.java /tmp/testme.java $svn commit !^ # equivalent to: svn commit /home/fred/mywork.java $mv /home/fred/downloads/sample_screen_config /home/fred/.screenrc $emacs !$ # equivalent to: emacs /home/fred/.screenrc $sudo cp /etc/apache2/sites-available/siteconfig /home/fred/siteconfig.bak $echo !^ !!:2 # equivalent to echo cp /etc/apache2/sites-available/siteconfig 16.5. Editing Arguments [introduces editing recalled arguments with s/foo/bar] $wc file1 $rm !$:s/1/2/ [expands to "rm file2"] $wc file1 $^1^2 [Expands to "wc file2"; RH: Check on Arch] 16.6. Searching through the Command History [Ctrl-R for "reverse-i-search"] 16.7. Sharing Bash History [update ~/.bashrc; hidden files and text editing have not yet been introduced; don't believe bash has been formally introduced] shopt -s histappend PROMPT_COMMAND='history -a' Terms: command history, bang operator, bash shell, .bashrc Commands: !, mv, log, sudo, history, !*, !^, !$, emacs, svn, cp, wc, rm 17. Permissions 17.1. What can I do? What can others do? [introduces files types; r, w, x permissions; users and groups; whoami; root] 17.2. Setting through chmod [introduces two ways to change permissions] $chmod u=rw,g=,o= motd $chmod 0660 issue 18. Interactive Editing [introduces concept of key bindings; shows how to set vim or emacs; detailed discussion of emacs keybindings; suggests explore vim on own; prior to discsussion of vim in book] 19. Checking Exit 19.1. Exit Status [introduces exit status; 0 success; $?] $echo $? 19.2. if/then [introduces compound command] 19.3. && and || 19.4. What does an exit status mean? 20. Sub Commands 20.1. Command Substitution [introduces commmand substitution; breifly introduces adding alias to .bashrc; hidden files, text editing not yet introduced] $grep `date +%b` apache_error_log .bashrc: alias monthlog="grep `date +%b` apache_error_log" $grep $(date +%b) apache_error_log 21. Moving Again [introduces dirctory stack; dirs; pushd dir; pushd; pushd +/- number; popd; illustrates state of state after various example commands] 22. Customizations 22.1. Useful customizations [intro text] 22.2. Variables [assigning, unassigning variables] $p=/home/jsmith/projects/foo/confoobulator $cd $p $VAR="" $unset VAR 22.3. Ordinary Variables and Environment Variables $export p 22.4. Shell Variables [describes severeal variables; SHELL, USER, PATH, etc.] $echo $HOME $env 22.5. Controlling Variable Expansion $curr=myfile $rm $curr1.jpeg # doesn't work $rm ${curr}1.jpeg # works 22.6. The Search Path [brief into to search path; introduction of which] 22.7. Configuration Files [introduction to hidden files; .bashrc; reference to text editor chapter] 23. Parameter Substitution 23.1. Parameter Substitution $curr=myfile $rm ${curr}.jpeg $rm ${curr/file/picture}.jpeg # to change file to picture and rm mypicture.jpg 23.2. Playing Safe With Variables That Don't Exist [introduces :- and :=] $cat "${VARIABLE_FILE_NAME:-/home/user/file}" $cat "${VARIABLE_FILE_NAME:=/home/user/file}" 23.3. Cutting Corners With Variable Expansion $export ALT_LS='--color=always -b -h --filetype' $ls $ALT_LS 24. GNU Screen [introduces screen and key combinations for: splitting, copy and paste, detaching, quitting] 25. SSH [intro to ssh, scp, rsync; discourages telnet; detached remoted session using screen] 25.1. SSH $ssh othermachine.domain.org $ssh -l remoteusername othermachine.domain.org $ssh remoteusername@othermachine.domain.org $ssh remoteusername@othermachine.domain.org 'mkdir /home/myname/newdir' 25.2. scp: file copying $scp myprog.py me@othermachine.domain.org:stuff $scp me@othermachine.domain.org:docs/interview.txt yesterday-interview.txt $scp user1@host1:file1 user2@host2:otherdir $scp -r user1@host1:dir1 user2@host2:dir2 25.3. rsync: automated bulk transfers and backups $rsync -e ssh -a /home/myname/docs me@quantum.example.edu:backup/ 25.4. Making life easier when you use SSH often [editing .ssh/config] 26. Git [list of basic git commands: clone, commit, revert; chapter appears incomplete] 27. Installing Software [basic commands for apt-get and yum; brief overview of compling from source] 27.1. Dependencies [introduction to topic] 27.2. Unpack the archive $tar zxvf packagename.tar.gz 27.3. Run the configure script $./configure $./configure --prefix ~/bin/myprogs 27.4. Compile the software $make $make -j3 27.5. Install the software $sudo make install 28. Making Your Own Interpreter [source code for bdc; compiling; usage] 29. Text Editors [including nano; omitting vim, emacs, kedit, gedit] 29.1. Text Editors [intro] 29.1.1. Word Processing vs Text Editing 29.1.2. Why do you need a text editor? 29.1.3. Why are most text editors command-line programs? 29.2. Setting a default text editor $export EDITOR=emacs 30. Nano [brief intro nano; basic use; start, save, exit] 31. Scripting 31.1. Scripting [intro; sample script] 31.2. Making scripts executable $chmod +x make_thumbnails.sh $./make_thumbnails.sh $bash make_thumbnails.sh 31.3. More Control [examples of if, while, etc.] 31.3.1. if 31.3.2. while (and until) 31.3.3. case 31.3.4. for 31.3.5. parallel 32. Maintaining Scripts [guidelines for maintainable, robust scripts; e.g., "Use descriptive names for your scripts"] 33. Other Languages [introduction; introduces awk, sed, python; other languages omitted] 34. Sed 34.1. The Sed Text Processor $wc -c * | sort -n | sed ... 34.2. Basic Syntax and Substitution $sed "s/foo/bar/g" inputfile > outputfile 34.3. Sed Experessions Explained [introduces $, ^, *, []] 34.4. Deletion $sed "/^$/d" inputfile > outputfile 34.5. Controlling Printing $sed -n "s/Mrs\./Ms/p" testfile 34.6. Multiple Patterns $echo Gnus eat grass | sed -e "s/Gnus/Penguins/" -e "s/grass/fish/" 34.7. Controlling Edits With Patterns $sed "/one/ s/number/1/" testfile > testchangedfile 34.8. Controlling Edits With Line Numbers $sed "2,3 s/number/1/" < testfile > testchangedfile 34.9. Scripting SED commands $sed -f sedcommands < inputfile > outputfile 35. Awk [basic intro to awk] 36. Regular Expressions [basic intro to regular expressions; operators, ranges, groups, anchoring, etc.] 37. Python [new chapter] 38. Glossary [update for second editing] Glossary terms that don't appear in text: aptitude, ash, aspell, bug report, character set, findutils, fontconfig, intltool, kernel-utils, lsof, openssh, syntax highlighting [some glossary terms only appear in Command Quickie] 39. Command Quickie [to be revised] Commands in order of presentation: ls, man, info apropos, pwd, cd, mkdir, rmdir, touch, rm, ln, cp, mv, whoami, passwd, ps, kill, chown, chmod, more, less, pg, cat, grep, df, echo, file, diff, wc, find, ftp, wget, tar, gzip, gunzip, zcat, bzip2, bunzip2, bzcat, lynx, mc, emacs, vi, nano, pico, pr, lpr, split 40. Outline [proposed outline for a future edition] 41. Credits
Markdown version with images
A markdown version of the "Introduction to the Command Line" is available on this wiki. It was created from the epub version available at https://archive.flossmanuals.net/_booki/command-line/command-line.epub.
Source files
Source files, albeit imperfect, are available here https://static.fsf.org/nosvn/gnu-press/source-files/books/Intro-to-Command-Line.zip