Linux Command Line and Shell Scripting Bible
Meme
Linux Torvalds
How to pronounce this name is quite curious, searched it, and someone even made a collection, oh ...
Shell
Terminal
A terminal is a user interface, while a shell is running inside a terminal. Early Terminals Ear...
What is Shell
A shell is a command-line interpreter that lets you interact with the operating system by typing ...
Command History
The Mysterious ^[[A First, start a new Shell /bin/sh. /bin/sh Then enter the following command,...
Basic Operations
Default Shell echo $SHELL /bin/bash If you start a new Shell in the current terminal (e.g., sw...
Command Type
Builtin Commands Builtin commands are implemented by the Shell itself, they run without starting...
Shell Variables
Shell variables are a general term. If you are using a specific shell, such as Bash, you can call...
Subshell
The definition of Subshell in some books or materials is unclear, and the explanations often cont...
Commands
Common Commands 1
MAN This command can view different sections of the manual pages. man man man - an interface to...
Common Commands 2
Sort Sorts lines of text files by default, non-numeric. sort - sort lines of text files Reverse...
GREP
Full name Global Regular Expression Print, originated from a Unix editor ed command g/re/p, where...
PS
PS stands for Process Status. man ps ps - report a snapshot of the current processes. Style ...
TOP
man top top - display Linux processes The top command defaults to sorting processes by CPU usag...
Terminate Process
Kill Command It's actually a tool for sending signals to processes, not necessarily killing them...
Compression
[todo]
Environment
Concept
Origins The environment variables in Linux originated from the design requirements of early UNIX...
Shell Startup Process
Startup Methods The startup methods of Shell will affect the loading process of environment vari...
Environment Variables
SHELL The current shell in use. printenv SHELL /bin/bash HOME The path to the user's home dir...
Shebang
Shebang is a special symbol in Unix and Unix-like operating systems, composed of the characters #...
Permission
User Managerment
Account /etc/passwd Linux uses the /etc/passwd file to store user account information. Because m...
Group Management
Relationship Primary Group When a user is created, a group with the same name is also created, w...
File Permission
Composition Structure -rwxr-xr-- The first character indicates the file type: -:File, such as ...
Acess Control List
Access Control List (ACL) is a more flexible and fine-grained permission management mechanism, us...
Process
Systemd
The first process of the system, with a process ID of 1. ps -p 1 PID TTY TIME CMD 1 ?...
File Descriptor
Basic Concepts A file descriptor (FD) is an integer identifier used to represent an open file or...
Pipe
Basic Concepts A pipe can use the output of one command as the input of the next command, repres...
LSOF
[todo]
ULIMIT
[todo]
File System
Script
Basic Syntax
Shebang #!/usr/bin/env bash Variable Assignment No spaces are allowed around the = sign. name=...
Condition
If Statement If the exit code of command is 0, then execute the content of then. if command then...
Loop
For Statement for var in list do ... done The var variable can be normally used outside the...
Input
Positional Parameters Positional Parameters, script positional parameters. $0: script name, inc...
Output
Standard File Descriptors Standard File Descriptors. Name Number Description STDIN 0 Stan...
Signal
Bash Shell By default, the Bash Shell ignores the SIGQUIT(3) and SIGTERM(15) signals, so executi...
Function
Creating a Function function name { commands } or name() { commands } Function Return...
Parameter Expansion
In Bash, parameter expansion is a mechanism for manipulating and handling the contents of variabl...
Special Parameters
Parameters: $? The exit code of the previous command or script, 0 for success, non-0 for failure...
Text
Multi-Lines Text
Echo Command Using the -e option can create simple multi-line text. echo -e 'aa\nbb' aa bb He...
Regular Expression
Regular Expressions (regex) can be divided into the following categories based on different stand...
SED
Stream Editor, a stream text processor, authored by Lee E. McMahon. Basic Syntax sed [OPTIONS] 'c...
GAWK 1
Gnu Awk Gawk is the GNU version of the text processing tool. In most GNU/Linux distributions, Ga...
GAWK 2
Regular Expression gawk defaults to using ERE mode. Basic Usage First, create the foo text file....