BANISH YOUR MOUSE ˆ ˇ ˝˛ THE LINUX ˚˛ ˇ ˝˛ COMMAND LINE · 2017-11-02 · The Linux...
Transcript of BANISH YOUR MOUSE ˆ ˇ ˝˛ THE LINUX ˚˛ ˇ ˝˛ COMMAND LINE · 2017-11-02 · The Linux...
You’ve experienced the shiny, point-and-click surface of your Linux computer—now dive below and explore its depths with the power of the command line.
The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you’ll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.
In addition to that practical knowledge, author William Shotts reveals the philosophy behind these tools and the rich heritage that your desktop Linux machine has inherited from Unix supercomputers of yore.
As you make your way through the book’s short, easily digestible chapters, you’ll learn how to:
• Create and delete files, directories, and symlinks
• Administer your system, including networking, package installation, and process management
B A N I S H Y O U R M O U S E
B A N I S H Y O U R M O U S E
• Use standard input and output, redirection, and pipelines
• Edit files with Vi, the world’s most popular text editor
• Write shell scripts to automate common or boring tasks
• Slice and dice text files with cut, paste, grep, patch, and sed
Once you overcome your initial “shell shock,” you’ll find that the command line is a natural and expressive way to communicate with your computer. Just don’t be surprised if your mouse starts to gather dust.
A B O U T T H E A U T H O R
William E. Shotts, Jr., has been a software professional and avid Linux user for more than 15 years. He has an extensive background in software development, including technical support, quality assurance, and documentation. He is also the creator of LinuxCommand.org, a Linux education and advocacy site featuring news, reviews, and extensive support for using the Linux command line.
SHELVE IN:
COMPUTERS/LINUX
$49.95 ($52.95 CDN)
www.nostarch.com
TH E F I N EST I N G E E K E NTE RTA I N M E NT™
FSC LOGO
“ I L I E F LAT .”
Th is book uses RepKover — a durab le b ind ing that won’t snap shut.
A C O M P L E T E I N T R O D U C T I O N
T H E L I N U XCO M M A N D L I N E
T H E L I N U XCO M M A N D L I N E
W I L L I A M E . S H O T T S , J R .
TH
E L
INU
X C
OM
MA
ND
LIN
ET
HE
LIN
UX
CO
MM
AN
D L
INE
SH
OT
TS
I N D E X
Symbols--help option, 42$*, 386$@, 386${!array[*]}, 420${!array[@]}, 420${!prefix*}, 402${!prefix@}, 402${#parameter}, 402${parameter:=word}, 400${parameter:-word}, 400${parameter:+word}, 401${parameter:?word}, 401${parameter//pattern/string}, 403${parameter/#pattern/string}, 403${parameter/%pattern/string}, 403${parameter/pattern/string}, 403${parameter##pattern}, 403${parameter#pattern}, 403${parameter%%pattern}, 403${parameter%pattern}, 403$!, 430$#, 382$((expression)), 404$0, 385./configure, 302.bash_history, 73.bash_login, 113.bash_profile, 112.bashrc, 113, 115, 312, 332, 385.profile, 113.ssh/known_hosts, 184/, 19
/bin, 19/boot, 19/boot/grub/grub.conf, 19/boot/vmlinuz, 19/dev, 20/dev/cdrom, 165/dev/dvd, 165/dev/floppy, 165/dev/null, 52/etc, 20/etc/bash.bashrc, 113/etc/crontab, 20/etc/fstab, 20, 160, 170/etc/group, 79/etc/passwd, 20, 79, 241, 245, 352/etc/profile, 112, 114/etc/shadow, 79/etc/sudoers, 87/lib, 20/lost+found, 20/media, 20/mnt, 20/opt, 20/proc, 21/root, 21, 88/sbin, 21/tmp, 21, 429/usr, 21/usr/bin, 21/usr/lib, 21/usr/local, 21/usr/local/bin, 21, 307, 312/usr/local/sbin, 312/usr/sbin, 21
The Linux Command Line © 2012 William E. Shotts, Jr.
/usr/share, 21/usr/share/dict, 219/usr/share/doc, 21, 45/var, 22/var/log, 22/var/log/messages, 22, 57, 166(( )) compound command, 404, 409[ command, 365
Aa2ps command, 292absolute pathnames, 9alias command, 46, 111aliases, 40, 46, 110American National Standards
Institute (ANSI), 142American Standard Code for
Information Interchange. See ASCII
anchors, 219anonymous FTP servers, 179ANSI (American National Standards
Institute), 142ANSI escape codes, 143ANSI.SYS, 142Apache web server, 104apropos command, 43apt-cache command, 152apt-get command, 152aptitude command, 152archiving, 205arithmetic expansion, 62, 65–66, 321,
399, 404arithmetic expressions, 62, 396, 404,
406, 416arithmetic operators, 62, 405arithmetic truth tests, 342, 404arrays
appending values to the end, 420assigning values, 416creating, 416deleting, 421determining number of
elements, 419finding used subscripts, 420index, 416
multidimensional, 416reading variables into, 348sorting, 420subscript, 416two-dimensional, 415
ASCII (American Standard Code for Information Exchange),17, 68, 71, 198, 222, 292
bell character, 140carriage return, 236collation order, 222, 224, 339control codes, 68, 222, 286groff output driver, 280linefeed character, 236null character, 198printable characters, 222text, 17
aspell command, 263assembler, 298assembly language, 298assignment operators, 407asynchronous execution, 429audio CDs, 163, 172AWK programming language,
263, 412
Bback references, 232, 260backslash escape sequences, 68backslash-escaped special
characters, 140backups, incremental, 208basename command, 385bash (shell) 3, 110
man page, 44basic regular expressions, 224, 231,
257, 260, 269bc command, 412Berkeley Software Distribution
(BSD), 290bg command, 102binary, 81–82, 85, 298, 405bit mask, 84bit operators, 409Bourne, Steve, 3brace expansion, 63, 65, 394
434 Index The Linux Command Line © 2012 William E. Shotts, Jr.
branching, 333break command, 360, 389broken links, 37BSD (Berkeley Software
Distribution), 290BSD-style behavior, 98buffering, 164bugs, 369–373build environment, 302bzip2 command, 204
CC programming language, 298,
396, 407, 410C++ programming language, 298cal command, 5cancel command, 296carriage return, 17, 68, 140,
222–223, 235, 262, 289case compound command, 376cat command, 53, 235cd command, 9–10cdrecord command, 172CD-ROMs, 162–163, 172cdrtools package, 172character classes, 26–27, 220-224,
227, 255, 262character ranges, 27, 220–221, 262chgrp command, 91child process, 96chmod command, 81, 92, 311chown command, 90, 92chronological sorting, 241cleartext, 179, 182client-server architecture, 431COBOL programming language, 298collation order, 111, 222, 224,
254, 339ASCII, 224, 339dictionary, 222traditional, 224
comm command, 249command history, 4, 73command line
arguments, 382editing, 4, 70
expansion, 59history, 4, 74interfaces, 26, 28
command options, 14command substitution, 64–65, 394commands
arguments, 14, 382determining type, 40documentation, 41executable program files, 40, 299executing as another user, 87long options, 14options, 14
comments, 114, 118, 262, 310, 371Common Unix Printing System
(CUPS), 288comparison operators, 409compiling, 298completions, 72compound commands
(( )), 342, 354, 404[[ ]], 341, 354case, 376for, 393if, 334until, 361while, 358
compression algorithms, 202conditional expressions, 366configuration files, 17, 20, 109configure command, 302constants, 319continue command, 360control characters, 141, 235control codes, 68, 222control operators
&&, 345, 354||, 345
controlling terminal, 96COPYING (documentation file), 301copying and pasting
on the command line, 70in vim, 129with X Window System, 5
coreutils package, 42, 44–45, 246counting words in a file, 55
Index 435The Linux Command Line © 2012 William E. Shotts, Jr.
cp command, 28, 33, 116, 185CPU, 95, 298cron job, 189crossword puzzles, 219csplit command, 266CUPS (Common Unix Printing
System), 288current working directory, 8cursor movement, 70cut command, 243, 403
Ddaemon programs, 96, 104data compression, 202data redundancy, 202data validation, 341date command, 5date formats, 241dd command, 171Debian, 150debugging, 330, 370defensive programming, 367, 370delimiters, 66, 239, 241dependencies, 151, 305design, 368, 370device drivers, 156, 298device names, 164device nodes, 20df command, 6, 331DHCP (Dynamic Host Configuration
Protocol), 178diction program, 300dictionary collation order, 222diff command, 250Digital Rights Management
(DRM), 151directories
archiving, 205changing, 9copying, 28creating, 28, 33current working, 8deleting, 31, 37hierarchical, 7home, 20, 79, 332listing, 13
moving, 30, 35navigating, 7OLD_PWD variable, 111parent, 8PATH variable, 111PWD variable, 112removing, 31, 37renaming, 30, 35root, 7shared, 91sticky bit, 86synchronizing, 211transferring over a network, 211viewing contents, 8
disk partitions, 161DISPLAY variable, 111Dolphin, 28dos2unix command, 236double quotes, 65dpkg command, 152DRM (Digital Rights
Management), 151du command, 238, 332Dynamic Host Configuration
Protocol (DHCP), 178
Eecho command, 60, 111, 316
-e option, 68-n option, 349
edge and corner cases, 370EDITOR variable, 111effective group ID, 86effective user ID, 86, 96elif statement, 339email, 234embedded systems, 298empty variables, 400encrypted tunnels, 185encryption, 255endless loop, 361end-of-file, 54, 322enscript command, 294environment, 88, 109, 353
aliases, 110establishing, 112
436 Index The Linux Command Line © 2012 William E. Shotts, Jr.
examining, 110login shell, 112shell functions, 110shell variables, 110startup files, 112subshells, 424variables, 110
eqn command, 279executable programs, 40, 299, 303
determining location, 41PATH variable, 111
exit command, 6, 338, 356exit status, 334, 338expand command, 246expansions, 59
arithmetic, 62, 65–66, 321, 399, 404
brace, 63, 65, 394command substitution,
64–65, 394delimiters, 66errors resulting from, 365history, 74–76parameter, 64, 65–66, 319,
323, 399pathname, 60, 65, 394tilde, 61, 65word splitting, 65
expressions arithmetic, 62, 396, 404, 406, 416conditional, 366
ext3 filesystem, 169extended regular expressions, 224Extensible Markup Language
(XML), 234
Ffalse command, 335fdformat command, 171fdisk command, 167fg command, 102FIFO (first-in, first-out), 431file command, 16file descriptor, 51File Transfer Protocol (FTP), 179
filenames, 198case sensitive, 11embedded spaces in, 11, 232extensions, 11hidden, 11
files access, 78archiving, 205, 209attributes, 79block special, 80block special device, 190changing file mode, 81changing owner and group
owner, 90character special, 80character special device, 190compression, 202configuration, 17, 109, 234copying, 28, 33copying over a network, 179creating empty, 51.deb, 150deleting, 31, 37, 195determining contents, 16device nodes, 20execution access, 79expressions, 336, 338, 340finding, 187hidden, 11ISO image, 172–173listing, 8, 13mode, 79moving, 30, 34owner, 81permissions, 78read access, 79regular, 190removing, 31, 37renaming, 30, 34–35.rpm, 150shared library, 20startup, 112sticky bit, 86symbolic links, 190synchronizing, 211temporary, 428
Index 437The Linux Command Line © 2012 William E. Shotts, Jr.
files (continued )text, 17transferring over a network, 179,
209, 211truncating, 51type, 79viewing contents, 17write access, 79
filesystem corruption, 164filters, 55find command, 189, 208firewalls, 176first-in, first-out (FIFO), 431floppy disks, 159, 165, 171flow control
branching, 333case compound command, 376elif statement, 339endless loop, 361for compound command, 393for loop, 393function statement, 327if compound command, 334looping, 357menu-driven, 355multiple-choice decisions, 375reading files with while and until
loops, 362terminating a loop, 360traps, 427until loop, 361while loop, 359
fmt command, 271focus policy, 5fold command, 271for compound command, 393for loop, 393Foresight, 150Fortran programming language,
298, 395free command, 6, 164Free Software Foundation, xxixfsck command, 170FTP (File Transfer Protocol), 179ftp command, 179, 186, 300, 323FTP servers, 179, 323
FUNCNAME variable, 385function statement, 327
Ggcc (compiler), 299gedit command, 101, 115genisoimage command, 172Gentoo, 150Ghostscript, 288gid (primary group ID), 78global variables, 328globbing, 26GNOME, 3, 28, 38, 84, 115, 186gnome-terminal, 3GNU binutils package, 395GNU C Compiler, 299GNU coreutils package, 42,
44–45, 246GNU Project, 14, 29, 300–301
info command, 44–45GNU/Linux, 29graphical user interface (GUI), xxvi,
5, 28, 38, 70, 84, 112grep command, 56, 216, 352groff command, 279group commands, 423groups, 78
effective group ID, 86primary group ID, 78
GUI (graphical user interface), xxvi, 5, 28, 38, 70, 84, 112
gunzip command, 202gzip command, 45, 202
Hhard disks, 159hard links, 23, 32, 35
creating, 35listing, 36
head command, 56header files, 302“hello world” program, 310help command, 41here documents, 321
438 Index The Linux Command Line © 2012 William E. Shotts, Jr.
here strings, 353hexadecimal, 82, 405hidden files, 11, 61hierarchical directory structure, 7high-level programming
languages, 298history
expansion, 74–76searching, 74
history command, 74home directories, 8, 10, 20, 61,
88, 111/etc/passwd, 79root account, 21
HOME variable, 111hostname, 140HTML (Hypertext Markup
Language), 234, 263, 279, 315, 326
Iid command, 78IDE, 165if compound command, 114,
365, 375IFS (Internal Field Separator)
variable, 351IMCP ECHO_REQUEST, 176incremental backups, 208info files, 45init program, 96init scripts, 96inodes, 36INSTALL (documentation file), 301installation wizard, 150integers
arithmetic, 62, 411division, 62, 405
interactivity, 347Internal Field Separator (IFS)
variable, 351interpreted languages, 299interpreted programs, 299interpreter, 299
I/O redirection, 49. See also redirection
ISO images, 172–173iso9660 (device type), 162, 173
Jjob control, 101job numbers, 101jobspec, 102join command, 247Joliet extensions, 173Joy, Bill, 122
Kkate command, 115KDE, 3, 28, 38, 84, 115, 186kedit command, 115kernel, xxv, xxix, 19, 43, 95, 104, 157,
165, 253, 305device drivers, 156
key fields, 239kill command, 103killall command, 106killing text, 70Knuth, Donald, 279Konqueror, 28, 84, 186konsole (terminal emulator), 3kwrite command, 101, 115
LLANG variable, 111, 222, 224less command, 17, 55, 211, 231lftp command, 181libraries, 299line editors, 122line-continuation character, 262, 313linker (program), 299linking (process), 298links
broken, 37creating, 32hard, 23, 32symbolic, 22, 33
Index 439The Linux Command Line © 2012 William E. Shotts, Jr.
Linux community, 149Linux distributions, 149
CentOS, 150, 294Debian, 150, 297Fedora, xxviii, 79, 150, 294Foresight, 150Gentoo, 150Linspire, 150Mandriva, 150OpenSUSE, xxviii, 150packaging systems, 149PCLinuxOS, 150Red Hat Enterprise Linux, 150Slackware, 150Ubuntu, xxviii, 149–150, 294Xandros, 150
Linux Filesystem Hierarchy Standard, 19, 312
Linux kernel, xxv, xxix, 19, 43, 95, 104, 157, 165, 253, 305
device drivers, 156literal characters, 218ln command, 32, 35local variables, 329locale, 222, 224, 254, 339locale command, 224localhost, 182locate command, 188, 230logical errors, 366logical operators, 192–193, 343logical relationships, 192, 195logical volume manager (LVM),
159, 162login prompt, 6, 180login shell, 79, 88, 112long options, 14loopback interface, 178looping, 357loops, 367, 406, 408, 422, 425lossless compression, 202lossy compression, 202lp command, 291lpq command, 295lpr command, 290lprm command, 296lpstat command, 294
ls command, 8, 13long format, 15viewing file attributes, 79
Lukyanov, Alexander, 181LVM (logical volume manager),
159, 162
Mmachine language, 298maintenance, 312, 316, 318, 325make command, 303Makefile, 303man command, 42man pages, 42, 280markup languages, 234, 279memory
assigned to each process, 96displaying free, 6RSS (Resident Set Size), 98segmentation violation, 105usage, 98, 106virtual, 98
menu-driven programs, 355meta key, 72metacharacters, 218metadata, 150, 152metasequences, 218mkdir command, 28, 33mkfifo command, 431mkfs command, 169, 171mkisofs command, 172mktemp command, 428mnemonics, 298modal editor, 124monospaced fonts, 288Moolenaar, Bram, 122mount command, 161, 173mount points, 20, 161, 163mounting, 160MP3 files, 91multiple-choice decisions, 375multitasking, 77, 95, 429multiuser systems, 77mv command, 30, 34
440 Index The Linux Command Line © 2012 William E. Shotts, Jr.
Nnamed pipes, 430nano command, 122Nautilus, 28, 84, 186netstat command, 178networking, 175
anonymous FTP servers, 179default route, 179Dynamic Host Configuration
Protocol (DHCP), 178encrypted tunnels, 185examining network settings and
statistics, 178File Transfer Protocol (FTP), 179firewalls, 176local area network (LAN), 179loopback interface, 178man-in-the-middle attacks, 182routers, 178secure communication with
remote hosts, 182testing whether a host is alive, 176tracing the route to a host, 177transferring files, 211transporting files, 179virtual private network, 185
newline characters, 66, 140NEWS (documentation file), 301nl command, 268nroff command, 279null character, 198number bases, 405
Ooctal, 82, 405, 418Ogg Vorbis files, 91OLD_PWD variable, 111OpenOffice.org Writer, 17OpenSSH, 182operators
arithmetic, 62, 405assignment, 407binary, 366comparison, 409ternary, 410
owning files, 78
Ppackage files, 150package maintainers, 151package management, 149
Debian style (.deb), 150finding packages, 152high-level tools, 152installing packages, 153low-level tools, 152package repositories, 151Red Hat style (.rpm), 150removing packages, 154updating packages, 154
packaging systems, 149page-description language, 234,
281, 287PAGER variable, 111pagers, 18parameter expansion, 64, 65–66,
319, 323, 399parent process, 96passwd command, 93passwords, 93paste command, 246PATA hard drives, 165patch command, 253patches, 250PATH variable, 111, 114, 311, 327pathname expansion, 60, 65, 394pathnames, 230
absolute, 9completion, 72relative, 9
PDF (Portable Document Format), 281, 290
Perl programming language, 40, 216, 263, 299, 412
permissions, 310PHP programming language, 299ping command, 176pipelines, 54, 353, 425
in command substitution, 64portability, 304, 332, 345Portable Document Format (PDF),
281, 292
Index 441The Linux Command Line © 2012 William E. Shotts, Jr.
Portable Operating System Inter-face (POSIX). See POSIX (Portable Operation System Interface)
positional parameters, 381, 400–402POSIX (Portable Operating Sys-
tem Interface), 222, 224–225, 345
character classes, 26, 221, 223–224, 227, 255, 262
PostScript, 234, 280, 287, 292pr command, 274, 288primary group ID (gid), 78printable characters, 222printenv command, 64, 110printers, 164
buffering output, 164control codes, 286daisy-wheel, 286device names, 165drivers, 288graphical, 287impact, 286laser, 287
printf command, 275, 398printing
determining system status, 294history of, 286Internet Printing Protocol, 295monospaced fonts, 286preparing text, 288pretty, 292proportional fonts, 287queues, 294, 295–296spooling, 294terminating print jobs, 296viewing jobs, 295
process ID, 96process substitution, 425processes, 95
background, 101child, 96controlling, 100foreground, 101interrupting, 101job control, 101killing, 103
nice, 97parent, 96process ID, 96SIGINT, 427signals, 103SIGTERM, 427sleeping, 97state, 97stopping, 102viewing, 96, 98zombie, 97
production use, 368programmable completion, 73ps command, 96PS1 variable, 112, 140PS2 variable, 317ps2pdf command, 281PS4 variable, 372pseudocode, 333, 358pstree command, 106PuTTY, 186pwd command, 8PWD variable, 112Python programming language, 299
Qquoting, 65
double quotes, 65escape character, 67missing quote, 364single quotes, 67
RRAID (redundant array of
independent disks), 159raster image processor (RIP), 288read command, 348–351, 362,
368, 425Readline, 70README (documentation file),
45, 301redirection
blocked pipe, 431group commands and
subshells, 424
442 Index The Linux Command Line © 2012 William E. Shotts, Jr.
here documents, 321here strings, 353standard error, 51standard input, 53, 323standard output, 50
redirection operators &>, 52>, 50>>, 51>(list), 425<, 54<<, 322–323<<-, 323<<<, 353<(list), 425|, 54
redundant array of independent disks (RAID), 159
regular expressions, 56, 215, 259, 341, 352
anchors, 219back references, 232, 259–260basic, 224, 231–232, 257, 260, 269extended, 224
relational databases, 247relative pathnames, 9“release early, release often,” 369removing duplicate lines in a file, 55REPLY variable, 348, 425report generator, 315repositories, 151return command, 328, 338RIP (raster image processor), 288rlogin command, 182rm command, 31Rock Ridge extensions, 173roff command, 279ROT13 encoding, 255rpm command, 152rsync command, 212rsync remote-update protocol, 212Ruby programming language, 299
Sscalar variables, 415Schilling, Jörg, 172
scp command, 185script command, 76scripting languages, 40, 299sdiff command, 266searching a file for patterns, 56searching history, 74Secure Shell (SSH), 182sed command, 256, 282, 403set command, 110, 371setuid, 86, 337Seward, Julian, 204sftp command, 186shared libraries, 20, 151shebang, 311shell builtins, 40shell functions, 40, 110, 327, 385shell prompts, 4, 9, 75, 88, 101, 112,
139, 183, 317shell scripts, 309SHELL variable, 111shell variables, 110shift command, 383, 388SIGINT signal, 427signals, 426single quotes, 67Slackware, 150sleep command, 360soft link, 22sort command, 55, 236sort keys, 239source code, 150, 156, 235, 297source command, 118, 312source tree, 300special parameters, 385, 401split command, 266SSH (Secure Shell), 182ssh program, 77, 183, 209Stallman, Richard, xxv, xxix, 116,
225, 299standard error, 50
disposing of, 52redirecting to a file, 51
standard input, 50, 323, 348redirecting, 53
standard output, 50appending to a file, 51disposing of, 52
Index 443The Linux Command Line © 2012 William E. Shotts, Jr.
standard output (continued )redirecting standard error to, 52redirecting to a file, 50
startup files, 112stat command, 199sticky bit, 86storage devices, 159
audio CDs, 163, 172CD-ROMs, 162–163, 172creating filesystems, 167device names, 164disk partitions, 161FAT32, 167floppy disks, 165, 171formatting, 167LVM, 162mount points, 161, 163partitions, 167reading and writing directly, 171repairing filesystems, 170unmounting, 163USB flash drives, 171
stream editor, 256, 282, 403strings
${parameter:offset}, 402${parameter:offset:length}, 402extract a portion of, 402length of, 402perform search and replace
upon, 403remove leading portion of, 403remove trailing portion of, 403
strings command, 395stubs, 330, 369style (program file), 302su command, 87subshells, 353, 423sudo command, 87–89Sun Microsystems, 122superuser, 4, 79, 88, 106symbolic links, 22, 33, 36
creating, 36, 38listing, 36
syntax errors, 363syntax highlighting, 310, 314
Ttables, 247tabular data, 239, 278tail command, 56tape archive, 205tar command, 205tarballs, 300targets, 303Task Manager, 100Tatham, Simon, 186tbl command, 279, 282tee command, 57teletype, 96telnet command, 182TERM variable, 112terminal emulators, 3terminal sessions
controlling the terminal, 96effect of .bashrc, 312environment, 88exiting, 6login shell, 88, 112with remote systems, 77TERM variable, 112using named pipes, 431virtual, 6
terminals, 71, 77, 142, 279ternary operator, 410test cases, 369test command, 336, 341, 359, 366test coverage, 370testing, 369–370TEX, 279text, 17
adjusting line length, 271ASCII, 17carriage return, 236comparing, 249converting MS-DOS to Unix, 254counting words, 55cutting, 243deleting duplicate lines, 242deleting multiple blank lines, 236detecting differences, 250displaying common lines, 249
444 Index The Linux Command Line © 2012 William E. Shotts, Jr.
displaying control characters, 235DOS format, 236EDITOR variable, 111expanding tabs, 246files, 17filtering, 55folding, 271formatting, 268formatting for typesetters, 279formatting tables, 282joining, 247linefeed character, 236lowercase to uppercase
conversion, 254numbering lines, 236, 268paginating, 274pasting, 246preparing for printing, 288removing duplicate lines, 55rendering in PostScript, 280ROT13 encoded, 255searching for patterns, 56sorting, 55, 236spell checking, 263substituting, 259substituting tabs for spaces, 246tab delimited, 245transliterating characters, 254Unix format, 236viewing with less, 17, 55
text editors, 115, 234, 254emacs, 116gedit, 115, 310interactive, 254kate, 115, 310kedit, 115kwrite, 115line, 122nano, 115, 122pico, 115stream, 256syntax highlighting, 310, 314vi, 115vim, 115, 310, 314visual, 122for writing shell scripts, 310
tilde expansion, 61, 65tload command, 106top command, 98top-down design, 326Torvalds, Linus, xxvtouch command, 198–199, 213,
305, 389tr command, 254traceroute command, 177tracing, 371transliterating characters, 254traps, 427troff command, 279true command, 335TTY (field), 96type command, 40typesetters, 279, 287TZ variable, 112
UUbuntu, 79, 89, 149, 222, 312umask command, 84, 92umount command, 163unalias command, 47unary operator expected (error
message), 366unary operators, 405unexpand command, 246unexpected tokens, 365uniq command, 55, 242Unix, xxviUnix System V, 290unix2dos command, 236unset command, 421until compound command, 361until loop, 361unzip command, 210updatedb command, 189upstream providers, 151uptime, 326uptime command, 331USB flash drives, 159, 171Usenet, 255USER variable, 110, 112
Index 445The Linux Command Line © 2012 William E. Shotts, Jr.
users/etc/passwd, 79/etc/shadow, 79accounts, 78changing identity, 87changing passwords, 93effective user ID, 86, 96home directory, 79identity, 78password, 79setuid, 86superuser, 79, 81, 86–87, 93
Vvalidating input, 353variables, 64, 318, 400
assigning values, 320, 406constants, 319declaring, 318, 320environment, 110global, 328local, 329names, 319, 401scalar, 415shell, 110
vfat filesystem, 170vi command, 121vim command, 232, 314virtual consoles, 6virtual private network (VPN), 185virtual terminals, 6visual editors, 122vmstat command, 106VPN (virtual private network), 185
Wwait command, 429wc command, 55web pages, 234wget command, 181What You See Is What You Get
(WYSIWYG), 286whatis command, 44which command, 41while compound command, 358wildcards, 26, 53, 60, 216, 221wodim command, 173word splitting, 65–67world, 78WYSIWYG (What You See Is What
You Get), 286
XX Window System, 5, 77, 185xargs command, 197xload command, 106xlogo command, 100XML (Extensible Markup
Language), 234
Yyanking text, 70yum command, 152
Zzgrep command, 232zip command, 209zless command, 45
446 Index The Linux Command Line © 2012 William E. Shotts, Jr.