Advanced Search
Search Results
45 total results found
Pipe
Basic Concepts A pipe can use the output of one command as the input of the next command, represented by the symbol | in the command-line environment, which is a form of one-way communication between processes, implemented based on file descriptors. Working ...
Systemd
The first process of the system, with a process ID of 1. ps -p 1 PID TTY TIME CMD 1 ? 00:00:04 systemd However, when we want to display detailed information, the result will be different. ps -p 1 -f UID PID PPID C STIME TTY TIME CMD r...
ULIMIT
[todo]
Linux Torvalds
How to pronounce this name is quite curious, searched it, and someone even made a collection, oh my god, haha. Definition of Linux According to Wikipedia, Linux is both a Unix-like kernel and a generic term for an open-source Unix-like operating system based...
Condition
If Statement If the exit code of command is 0, then execute the content of then. if command then ... fi Another form. if command; then ... fi Else if command; then ... else ... fi Elif if command; then ... elif command; then ... fi ...
Function
Creating a Function function name { commands } or name() { commands } Function Return Value There are multiple forms of return values. Using $? Represents the exit status code of the last command in the function. echo $? Using Return #!/usr/bin/en...
Input
Positional Parameters Positional Parameters, script positional parameters. $0: script name, including path. $1: the first argument, and so on. ${10}: arguments greater than 9 need to use curly braces. #!/usr/bin/env bash echo $0 echo $1 ./foo a ./foo a ...
Loop
For Statement for var in list do ... done The var variable can be normally used outside the loop body. #!/usr/bin/env bash for var in apple banana do echo "hello $var" done echo "outside $var" hello apple hello banana outside var Storing a list in...
Output
Standard File Descriptors Standard File Descriptors. Name Number Description STDIN 0 Standard Input STDOUT 1 Standard Output STDERR 2 Standard Error Standard Input The cat command reads content from the standard input by default. If you run cat ...
Parameter Expansion
In Bash, parameter expansion is a mechanism for manipulating and handling the contents of variables. Through parameter expansion, you can get the value of a variable, modify the value of a variable, or provide a default value for an unset variable. Shell Param...
Signal
Bash Shell By default, the Bash Shell ignores the SIGQUIT(3) and SIGTERM(15) signals, so executing the following commands will not have any effect ($$ is the process ID of the current Shell). kill -3 $$ kill -15 $$ If the SIGHUP(1) signal is received, the B...
Special Parameters
Parameters: $? The exit code of the previous command or script, 0 for success, non-0 for failure. ls 404 echo $? Will output 2, indicating failure. The return code can be specified in scripts using exit. Parameters: $# Indicates the number of arguments pas...
Basic Syntax
Shebang #!/usr/bin/env bash Variable Assignment No spaces are allowed around the = sign. name=foo Double Quotes Can interpret variables. name=foo echo "hello, $name" # hello, foo echo "hello, \$\$" # hello, $$ echo "hello, \"\"" # hello, "" Single Quo...
Basic Operations
Default Shell echo $SHELL /bin/bash If you start a new Shell in the current terminal (e.g., switching from Bash to Zsh), this command still displays the default login Shell, which is configured in /etc/passwd. grep root /etc/passwd root:x:0:0:root:/root:/b...
Command History
The Mysterious ^[[A First, start a new Shell /bin/sh. /bin/sh Then enter the following command, everything is normal. ls -l Press the up arrow key ⬆️ to view the previous command. ^[[A You will find that you cannot see the previous command, instead, these ...
Command Type
Builtin Commands Builtin commands are implemented by the Shell itself, they run without starting a new process or calling an external program, which is the basic functionality of Shell operations. Builtin Commands Ex cd:Change the current working directory. ...
What is Shell
A shell is a command-line interpreter that lets you interact with the operating system by typing and executing commands. GNU Bash Manual Bash is the default Shell in Linux, the official manual is forever divine. Bash Reference Manualhttps://www.gnu.org/softwa...
Subshell
The definition of Subshell in some books or materials is unclear, and the explanations often contradict each other, making it difficult to understand. Therefore, to avoid this semantic and logical problem, we will not provide its definition (it is recommended ...
Terminal
A terminal is a user interface, while a shell is running inside a terminal. Early Terminals Early terminals were standalone hardware devices used to connect to main computers or servers. They typically included: Input Device: such as a keyboard, used for in...
GAWK 1
Gnu Awk Gawk is the GNU version of the text processing tool. In most GNU/Linux distributions, Gawk is the default awk implementation, so there is usually no difference in daily use. readlink -f /usr/bin/awk /usr/bin/gawk The Gawk command defaults to using E...