The Linux Command Line: A Complete Introduction

The Linux Command Line: A Complete Introduction

Language: English

Pages: 480

ISBN: 1593273894

Format: PDF / Kindle (mobi) / ePub


ou'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 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.

 

 

 

 

 

 

 

 

 

 

 

 

 

read is executed in a subshell. Subshells in Unix-like systems create copies of the environment for the processes to use while they execute. When the processes finish, the copy of the environment is destroyed. This means that a subshell can never alter the environment of its parent process. read assigns variables, which then become part of the environment. In the example above, read assigns the value foo to the variable REPLY in its subshell’s environment, but when the command exits, the

is actually doing and why. Finding bugs can sometimes involve a lot of detective work. A well-designed script will try to help. It should be programmed defensively to detect abnormal conditions and provide useful feedback to the user. Sometimes, however, problems are strange and unexpected, and more involved techniques are required. Finding the Problem Area In some scripts, particularly long ones, it is sometimes useful to isolate the area of the script that is related to the problem.

reveals the differences: [me@linuxbox ˜]$ posit-param3 $* : $1 = word $2 = words $3 = with $4 = spaces "$*" : $1 = word words with spaces $2 = $3 = $4 = $@ : $1 = word $2 = words $3 = with $4 = spaces "$@" : $1 = word $2 = words with spaces $3 = $4 = With our arguments, both $* and $@ produce a four-word result: word, words, with, and spaces. "$*" produces a one-word result: word words with spaces. "$@" produces a two-word result: word and words with spaces. This

William Shotts By default, sort sees this line as having two fields. The first field contains the characters William and the second field contains the characters Shotts, meaning that whitespace characters (spaces and tabs) are used as delimiters between fields and that the delimiters are included in the field when sorting is performed. Looking again at a line from our ls output, we can see that a line contains eight fields and that the fifth field is the file size: -rwxr-xr-x 1 root root

formatting. Plain ASCII text files contain only the characters themselves and a few rudimentary control codes like tabs, carriage returns, and linefeeds. Throughout a Linux system, many files are stored in text format, and many Linux tools work with text files. Even Windows recognizes the importance of this format. The well-known Notepad program is an editor for plain ASCII text files. * * * The less command is used like this: less filename Once started, the less program allows you

Download sample

Download