The second edition of Linux command line is coming! What updates have been made to this edition?

What kind of book is the second edition of Linux command line encyclopedia

This is a comprehensive book about the use of Linux command line. In a broader sense, this book teaches you how to use CLI, how CLI works, what functions CLI has, and what best practices are.

This is not a book about Linux operating system management. Any serious discussion about the command line will inevitably turn to the topic of operating system management. This book only touches on a few management issues. In order to enable you to carry out follow-up learning, this book provides a solid command-line foundation, which is an essential tool for completing important system management tasks.

This book focuses on Linux and only discusses the current Linux distribution. Although 95% of the content of this book is also helpful to users of other UNIX systems, this book is mainly for current Linux command line users.

 

What's new in version 2

Although the basic structure and content remain unchanged, the second edition has made various improvements, updates and kept pace with the times, many of which are based on readers' feedback. In addition, there are two special improvements. First, this book now assumes bash 4 x. This version was not widely used at the time of the first draft. Bash's 4 Version x has added some new features, which we will not miss. Secondly, the fourth part of the book is updated to provide better script practice examples. The script included in part 4 has been revised to make it more robust, and I have fixed several errors.

Why use the command line

Have you noticed that the "super hackers" (those who can break into extremely secure computers in less than half a minute) in the movie never touch the mouse when sitting in front of the computer? This is because the producer knows that as human beings, we know instinctively that the way to really "get everything" on the computer is to enter commands through the keyboard!

Most computer users today are only familiar with Graphical User Interface (GUI), and even a few manufacturers and experts say that Command Line Interface (CLI) is a thing of the past. It's a pity that a good cli is a very expressive way of human-computer interaction, just like the communication of letters between people. "The GUI makes simple tasks easier, while the CLI makes it possible to accomplish difficult tasks." This sentence is still correct today.

Since the Linux operating system refers to the UNIX series operating system, it shares the rich command-line tools of UNIX. UNIX operating system was the mainstream in the early 1980s (although it was developed in the 1970s), GUI was not widely used at that time, so a large number of CLI was born. In fact, one of the main reasons why early practitioners of Linux chose Linux over Windows NT was that its powerful cli made it possible to "complete difficult tasks".

You who study this book

This book is suitable for new users who switch from other operating systems to Linux. You may have been a "master" of a certain version of Windows; It may also be that the boss asked you to manage the Linux server, or you walked into the magical new world of Single Board Computer (SBC) such as raspberry pie; Or desktop users who are tired of various security problems and want to experience the Linux operating system. That's all right. Welcome to read.

That said, everything is difficult at the beginning, and learning the command line is no exception. Learning the command line is a challenge that requires hard work. This is not to say how difficult it is, but that it covers a wide range of contents. In the ordinary Linux operating system, there are thousands of programs that can be used on the command line, which is no exaggeration. Remind yourself that learning the command line is not easy.

However, learning the Linux command line pays off. If you think you're a "master", wait a minute. You don't know anything about real power. Moreover, regardless of other computer skills, command-line knowledge is enduring. What you learned today will still work in 10 years. Command line knowledge can stand the test of time.

If you don't have programming experience and don't worry, you can still start with this book.

Content structure of Linux command line encyclopedia version 2

The content of this book is carefully arranged. When reading, you will feel like a teacher sitting next to you, guiding you hand in hand. Many authors may take a systematic approach to explaining the contents of the book. From my point of view, this is reasonable, but for beginners, it may be confusing.

Another goal of this book is to familiarize you with the way UNIX thinks, which is different from the way Windows thinks. In the process, we will also help you understand how the command line works. Linux is not only a software, but also a small part of the huge UNIX culture. It has its own language and history.

This book includes four parts, each of which covers the knowledge of different aspects of the command line.

·Part I: Learn Shell. This part starts the learning journey of the basic knowledge of command line, including command structure, browsing file system, editing command line and finding command help and documents.

·Part II: configuration and environment. This section describes how to edit the configuration file and control the computer operation through the command line.

·Part III: common tasks and necessary tools. This section explores many of the general tasks that are performed on the command line. UNIX like systems, such as Linux, contain a large number of "classic" command-line programs that can be used to perform powerful operations on data.

·Part IV: write Shell script. This part introduces Shell programming, which is a recognized basic technology, but it is not difficult to learn. Many common computing tasks can be automated with it. By learning Shell programming, you will be familiar with some concepts that can also be applied to other programming languages.

The preparatory knowledge you need before learning

In order to read this book, you only need to install the Linux operating system. It can be realized in any of the following ways.

Install Linux on your computer (not the latest). No matter which Linux distribution you choose, there is no problem, but most people will choose from Ubuntu, Fedora and OpenSUSE. If you're not sure, Try Ubuntu first. When installing a modern Linux distribution, due to different hardware configurations, it is either extremely simple or appalling. It is recommended to use desktop computers for nearly two years, with at least 2GB of memory and 6GB of free disk space. Avoid using laptops and wireless networks as much as possible, as they are often difficult to work properly.

Use LiveCD or USB flash drive. Many Linux distributions have a cool feature. You can run Linux directly from CD-ROM or USB flash drive without installing it at all. Just enter the BIOS Setup interface, set the computer to boot from CD-ROM or USB device, and then restart. Using this method, the hardware compatibility can be well tested before installation. The disadvantage of Linux is that it runs slowly on the hard disk. Both Ubuntu and Fedora (and other distributions) have live CD versions.

No matter which way you install Linux, you will occasionally need super user (i.e. administrator) permission to complete some tasks in this book.

After installation, you can practice while reading. Most of the content of this book needs to be learned "by yourself".

Why not use the title of "GNU/Linux"


In some groups, the Linux operating system is called "GNU/Linux operating system". In fact, there is no right way to call "Linux", because it is created by developers all over the world. Technically speaking, Linux is just the name of the operating system kernel, that's all. The kernel is naturally very important. Without it, the operating system cannot run, but it is not enough to form a complete operating system.

Richard Matthew stoeman is a "gifted philosopher". He launched the free software movement, established the free software foundation, created the free software project, wrote the first version of the GNU C language compiler (GCC), and formulated the GNU General Public License (GPL). He insisted on calling Linux "GNU/LINUX" in order to accurately reflect the contribution of the GNU Project to the Linux operating system. Although the GNU Project appeared before the Linux kernel, its contribution is obvious to all and can not be ignored. But adding GNU to the name is unfair to others who have made great contributions to the development of Linux operating system. In addition, because the Linux kernel starts before other programs, I think the name "Linux/GNU" is more technically accurate.

In the current popular name, "Linux" refers to the kernel and all other free and open source software in a typical Linux distribution, that is, the whole Linux ecosystem, not just a part of GNU. The operating system market seems to prefer single word names, such as DOS, Windows, macOS, Solaris, Irix, AIX. I also choose to use this name. But if you prefer "GNU/Linux", please perform the "find replace" operation in your mind when reading.

Detailed catalogue

Part I learning Shell
 
Chapter 1 what is Shell	3
1.1  Terminal Emulator 	3
1.2  Small trial ox knife	4
1.2.1  Command history	4
1.2.2  Cursor movement	4
1.3  A few simple commands	5
1.4  End terminal session	6
1.5  summary	6
 Chapter 2 navigation	7
2.1  Understanding file system trees	7
2.2  Current working directory	8
2.3  List directory contents	8
2.4  Change current working directory	9
2.4.1  absolute path name	9
2.4.2  Relative pathname	9
2.4.3  Some useful and convenient ways to write	11
2.5  summary	11
 Chapter 3 exploration Linux system	12
3.1  use ls Joy of command	12
3.1.1  Options and parameters	13
3.1.2  Learn more about long format	14
3.2  use file The command determines the file type	15
3.3  use less Command view text file	15
3.4  look for a noble steed to correspond with the one drawn	17
3.5  Symbolic link	19
3.6  Hard link	20
3.7  summary	20
 Chapter 4 operation documents and directories	21
4.1  wildcard	22
4.2  mkdir-Create directory	24
4.3  cp-Copy files and directories	24
4.4  mv-Move and rename files	25
4.5  rm-Delete files and directories	26
4.6  ln-Create hard and symbolic links	27
4.6.1  Hard link	27
4.6.2  Symbolic link	28
4.7  Actual combat drill	28
4.7.1  Create directory	28
4.7.2  Copy file	29
4.7.3  Move and rename files	29
4.7.4  Create hard link	30
4.7.5  Create symbolic links	31
4.7.6  Delete files and directories	32
4.8  summary	34
 Chapter 5 dealing with orders	35
5.1  What is the order	35
5.2  Recognition command	36
5.2.1  type—Display command type	36
5.2.2  which—Show executable
 File location	36
5.3  Get command document	37
5.3.1  help—obtain Shell Built in
 Help information for the command	37
5.3.2  --help—Display usage information	38
5.3.3  man—Displays the of the command
 Man page	38
5.3.4  apropos—Display appropriate
 list commands	40
5.3.5  whatis—Displays the of the man page
 sketch	40
5.3.6  info—Displays the of the program info
 entry	41
5.3.7  Document file	42
5.4  use alias Create your own commands	42
5.5  summary	44
 Chapter 6 redirection	45
6.1  Standard input, standard output and
 Standard error	45
6.2  Standard output redirection	46
6.3  Standard error redirection	47
6.3.1  Compare standard output and standard error
 Redirect to the same file	48
6.3.2  Discard unwanted output	48
6.4  Standard input redirection	49
6.5  The Conduit	50
6.5.1  Sort list	51
6.5.2  uniq—Report or ignore
 Repeat line	52
6.5.3  wc—Line breaks in statistical files
 Number of words and bytes	52
6.5.4  grep—Output and mode
 Matching rows	53
6.5.5  head/tail—Output file
 start/end part	53
6.5.6  tee—Read standard input
 And write the output results to
 Standard output and documentation	54
6.6  summary	55
 Chapter 7“ Shell See the world with "eyes"	56
7.1  extend	56
7.1.1  Pathname extension	57
7.1.2  Ripple extension	58
7.1.3  Arithmetic extension	59
7.1.4  brace expansion 	60
7.1.5  Parameter extension	61
7.1.6  Command replacement	61
7.2  quote	62
7.2.1  Double quotation mark	62
7.2.2  Single quotation mark	64
7.2.3  Escape character	64
7.2.4  Backslash escape sequence	65
7.3  summary	65
 Chapter 8 advanced keyboard skills	66
8.1  Edit command line	66
8.1.1  Cursor movement	67
8.1.2  Modify text	67
8.1.3  Cut and paste text	67
8.2  programmable completion 	68
8.3  command history	70
8.3.1  Search history	70
8.3.2  Historical expansion	71
8.4  summary	72
 Chapter 9 authority	73
9.1  Owner, group and other users	74
9.2  Read, write, and execute	75
9.2.1  chmod—Modify file
 pattern	76
9.2.2  use GUI Set file mode	79
9.2.3  umask—Set default permissions	79
9.2.4  Some special permissions	80
9.3  Change user identity	81
9.3.1  su—As another user
 start-up Shell	82
9.3.2  sudo—Execute commands as another user	83
9.3.3  chown—Change file ownership and
 Genus group	84
9.3.4  chgrp—Change file group	85
9.4  Exercise authority	85
9.5  Change Password	87
9.6  summary	88
 Chapter 10 process	89
10.1  How the process works	90
10.2  View process	90
10.3  Process control	94
10.3.1  Interrupt process	94
10.3.2  Put process in background	95
10.3.3  Return the process to the foreground	95
10.3.4  Stop process	96
10.4  signal	96
10.4.1  use kill Send command to process
 signal	97
10.4.2  use killall Command to multiple
 Process send signal	98
10.5  Shut down the system	99
10.6  More process related commands	99
10.7  summary	100
 
Part II configuration and environment
 
Chapter 11 environment	103
11.1  What is saved in the environment	103
11.1.1  Check environment	104
11.1.2  Some noteworthy environments
 variable	105
11.2  How to establish environment	106
11.3  Modify environment	108
11.3.1  Which files should be modified	108
11.3.2  text editor	109
11.3.3  Using a text editor	109
11.3.4  Make changes effective	112
11.4  summary	112
 Chapter 12  Vi introduction	113
12.1  Why study Vi	113
12.2  background knowledge 	114
12.3  Start and exit Vi	114
12.4  Edit mode	116
12.4.1  Enter insert mode	116
12.4.2  Save file	117
12.5  Cursor movement	117
12.6  Basic editing	118
12.6.1  Add	118
12.6.2  newly build	119
12.6.3  delete	120
12.6.4  Cut, copy and paste	121
12.6.5  merge	122
12.7  Search and replace	122
12.7.1  In line search	122
12.7.2  Search entire file	122
12.7.3  Global search and replace	123
12.8  Edit multiple files	124
12.8.1  Switch between files	125
12.8.2  Load more files for
 edit	125
12.8.3  Copy the contents of a file to
 Another file	126
12.8.4  Insert the entire file into another
 file	127
12.9  Save work	128
12.10  summary	128
 Chapter 13 custom prompt	129
13.1  Decomposition prompt	129
13.2  Change the prompt	131
13.3  Add color	132
13.4  Move Cursor 	134
13.5  Save prompt	135
13.6  summary	135
 
Part III common tasks and necessary tools
 
Chapter 14 software package management	139
14.1  packaging system 	140
14.2  How packages work	140
14.2.1  Package file	140
14.2.2  Warehouse	141
14.2.3  dependence	141
14.2.4  Low and high level tools	141
14.3  Common software package management tasks	142
14.3.1  Find packages in the warehouse	142
14.3.2  Install packages in the warehouse	142
14.3.3  Install the in the package file
 software package	142
14.3.4  Delete package	143
14.3.5  Update software package through warehouse	143
14.3.6  Update via package file
 software package	144
14.3.7  List installed packages	144
14.3.8  Determine if the package is installed	144
14.3.9  Displays the of installed packages
 Relevant information	145
14.3.10  Identify which file is
 Package installed	145
14.4  summary	145
 Chapter 15 storage media	147
15.1  Mounting and unloading of storage devices	148
15.1.1  View mounted file systems
 list	149
15.1.2  Determine device name	152
15.2  Create a new file system	154
15.2.1  use fdisk Operation partition	154
15.2.2  use mkfs Create a new file
 system	156
15.3  Inspection and repair of file system	157
15.4  Move data directly between devices	158
15.4.1  To recordable CD Write data	159
15.4.2  establish CD-ROM of ISO
 Image file	159
15.4.3  Create with file collection ISO
 Image file	159
15.5  write in CD-ROM of ISO image
 file	160
15.5.1  Direct mount ISO image
 file	160
15.5.2  Erase recordable CD	161
15.5.3  Burn image file	161
15.6  summary	161
 Chapter 16 networking	162
16.1  Network inspection and monitoring	163
16.1.1  ping	163
16.1.2  traceroute	164
16.1.3  ip	165
16.1.4  netstat	165
16.2  Transfer files over the network	166
16.2.1  ftp	167
16.2.2  lftp-better ftp	168
16.2.3  wget	168
16.3  Secure communication with remote host	169
16.3.1  ssh	169
16.3.2  scp And sftp	172
16.4  summary	173
 Chapter 17 finding documents	174
17.1  locate-Simple file lookup
 method	174
17.2  find-Complex file lookup
 method	176
17.2.1  Test conditions	176
17.2.2  Operator	178
17.2.3  Predefined actions	180
17.2.4  User defined actions	182
17.2.5  increase of efficiency	182
17.2.6  xargs	183
17.2.7  Actual combat drill	184
17.2.8  find Command options	185
17.3  summary	186
 Chapter 18 archiving and backup	187
18.1  Compressed file	187
18.1.1  gzip	188
18.1.2  bzip2	190
18.2  File archiving	191
18.2.1  tar	191
18.2.2  zip	195
18.3  Synchronize files and directories	196
18.4  summary	199
 Chapter 19 regular expressions	200
19.1  What is a regular expression	200
19.2  grep	201
19.3  Metacharacter and literal character	202
19.4  Any character	203
19.5  Anchor point	203
19.6  Square bracket expression and character class	204
19.6.1  exclude	205
19.6.2  Traditional character range	205
19.7  POSIX Character class	206
19.8  POSIX Basic regular expressions and
 Extended regular expression	209
19.9  Multiple choice structure	210
19.10  classifier	211
19.10.1  ?-Matches 0 or 1 times	211
19.10.2  *-Matches 0 or more times	212
19.10.3  +-Match 1 or more times	212
19.10.4  {}-Match specified times	213
19.11  Actual combat drill	213
19.11.1  use grep Verify phone number
 list	213
19.11.2  use find Find pathname	214
19.11.3  use locate search for file	215
19.11.4  use Less and Vim search
 text	215
19.12  summary	217
 Chapter 20 text processing	218
20.1  Application of text	219
20.1.1  file	219
20.1.2  Webpage	219
20.1.3  E-mail	219
20.1.4  Printer output	219
20.1.5  program source code	219
20.2  new	220
20.2.1  cat—Connect files and
 Print	220
20.2.2  sort—sort	221
20.2.3  uniq—Delete duplicate lines	227
20.3  slice and dice 	228
20.3.1  cut-Delete from each row
 Part content	229
20.3.2  paste-Merge row	231
20.3.3  join-Connect two files
 Rows with common fields	233
20.4  Compare text	235
20.4.1  comm-Compare two lines line by line
 Sorted files	235
20.4.2  diff-Compare files line by line	236
20.4.3  patch-Apply to original file
diff file	238
20.5  Instant editing	239
20.5.1  tr-Transcribe or delete characters	239
20.5.2  sed-For text filtering and
 Converted stream editor	240
20.5.3  aspell-Interactive spelling
 Inspector	247
20.6  summary	250
 Chapter 21 formatted output	251
21.1  Simple formatting tool	251
21.1.1  nl-Number rows	252
21.1.2  fold-At the specified length
 Fold line	254
21.1.3  fmt-A simple text
 Formatting tool	255
21.1.4  pr-Format to output
 text	258
21.1.5  printf-Format and output
 data	259
21.2  Document formatting system	261
21.3  summary	267
 Chapter 22 printing	268
22.1  Print a brief history	268
22.1.1 ""Dark" era	269
22.1.2  Character based printer	269
22.1.3  Graphic printer	270
22.2  Linux Printing function of	271
22.3  Preparing documents for printing	271
22.4  Send print job to printer	272
22.4.1  lpr—with Berkeley style
 print document	272
22.4.2  lp—with System V style
 print document	273
22.4.3  a2ps—stay PostScript
 Print files on printer	274
22.5  Monitor print jobs	276
22.5.1  lpstat-Display printing system
 state	276
22.5.2  lpq-Show print queue
 state	277
22.5.3  lprm/cancel-cancel printing
 task	278
22.6  summary	278
 Chapter 23 compiler	279
23.1  What is compilation	280
23.2  compile C program	281
23.2.1  Get source code	281
23.2.2  Check the source tree	283
23.2.3  Build program	284
23.2.4  erection sequence	288
23.3  summary	288
 
Part IV preparation Shell script
 
Chapter 24 writing the first script	291
24.1  What is Shell script	291
24.2  How to create and execute Shell script	292
24.2.1  Script file format	292
24.2.2  Executable permissions	293
24.2.3  Script location	293
24.2.4  Ideal location for scripts	294
24.3  More formatting skills	294
24.3.1  Long option	295
24.3.2  Indent and continuation	295
24.4  summary	296
 Chapter 25 start up project	297
25.1  Phase 1: minimize documents	297
25.2  Phase 2: add data	299
25.3  Variables and constants	300
25.3.1  Assign values to variables and constants	302
25.3.2  here document	304
25.4  summary	306
 Chapter 26 top down design	307
26.1  Shell function	308
26.2  local variable	311
26.3  Keep script execution	312
26.4  summary	315
 Chapter 27 process control: if branch	316
27.1  if sentence	317
27.2  Exit status	317
27.3  use test	319
27.3.1  File expression	319
27.3.2  String expression	322
27.3.3  Integer expression	323
27.4  More modern test	324
27.5  (())-Design for integer	325
27.6  Combination expression	326
27.7  Control operator: another branch
 mode	329
27.8  summary	329
 Chapter 28 reading keyboard input	331
28.1  read-Read value from standard input	332
28.1.1  option	334
28.1.2  IFS	336
28.2  Verify input	338
28.3  menu	339
28.4  summary	341
 Chapter 29 process control: while/until loop	342
29.1  loop	342
29.2  Jump out of loop	345
29.3  Use loop to read files	347
29.4  summary	348
 Chapter 30 fault diagnosis	349
30.1  syntax error	349
30.1.1  Missing quotation mark	350
30.1.2  Missing lexical unit	351
30.1.3  Unexpected expansion	351
30.2  Logical error	353
30.2.1  Defensive programming	353
30.2.2  Be careful with file names	354
30.2.3  Verify input	355
30.3  test	355
30.4  debugging	357
30.4.1  Find problem area	357
30.4.2  track	357
30.4.3  Check values during execution	359
30.5  summary	360
 Chapter 31 process control: case branch	361
31.1  case command	361
31.1.1  pattern	363
31.1.2  Perform multiple operations	365
31.2  summary	366
 Chapter 32 location parameters	367
32.1  Access command line	367
32.1.1  Determine the number of parameters	369
32.1.2  shift-Access multiple parameters	369
32.1.3  Simple application	371
32.1.4  stay Shell Used in function
 Position parameter	371
32.2  Batch processing location parameters	372
32.3  A more complete application	374
32.4  summary	377
 Chapter 33 process control: for loop	380
33.1  for Traditional form of	380
33.2  for of C linguistic form	383
33.3  summary	384
 Chapter 34 strings and numbers	387
34.1  Parameter extension	387
34.1.1  Basic parameters	388
34.1.2  Manage null variable extensions	388
34.1.3  Returns the extension of the variable name	390
34.1.4  String operation	390
34.1.5  toggle case	393
34.2  Arithmetic evaluation and extension	395
34.2.1  Digital cardinality	395
34.2.2  unary operator	395
34.2.3  Simple arithmetic	395
34.2.4  assignment	397
34.2.5  Bit operation	399
34.2.6  Logical operation	399
34.3  bc-Arbitrary precision calculator language	401
34.3.1  use bc	402
34.3.2  Sample script	403
34.4  summary	404
 Chapter 35 array	405
35.1  What is an array	405
35.1.1  Create array	406
35.1.2  Assign a value to an array	406
35.1.3  Accessing array elements	406
35.2  Array operation	408
35.2.1  Output the entire contents of the array	408
35.2.2  Determines the number of array elements	409
35.2.3  Find the index used by the array	410
35.2.4  Add elements to the end of the array	410
35.2.5  Array sorting	410
35.2.6  Delete array	411
35.3  Associative array	412
35.4  summary	412
 Chapter 36 other orders	413
36.1  Grouping commands and sub commands Shell	413
36.2  trap	419
36.3  use wait Realize asynchronous execution	421
36.4  Named Pipe	423
36.4.1  Create named pipe	423
36.4.2  Use named pipes	424
36.5  summary	424

Tags: Linux shell Operating System

Posted by britey on Wed, 13 Apr 2022 20:49:15 +0930