For an operating system, the shell is equivalent to a layer of shell outside the kernel kernel as a user interface.
Generally speaking, the interface of the operating system is divided into two categories:
Cli:command Lines Interface Command line interface
Common: sh csh ksh zsh bash tcsh
Gui:graphical user Interface GUI
Common: Gnome KDE XFCE
Bash and its features:
1, bash is essentially an executable program, a user's working environment.
2, under each shell can open another shell, the newly opened shell can be called child shell, between each shell
Are independent of each other.
3. You can use the Pstree command to see the number of child shells under the current shell.
Use:
command-line editing:
Cursor Jump:
Ctrl + A: Jump to the beginning of the command line
Ctrl + E: Skip to command line line bit
Ctrl + D: Delete the character of the cursor
Ctrl + u: Removes all characters from the cursor to the beginning of the command line
Ctrl + K: Remove all characters from the cursor to the end of the command line
Ctrl + L: Clear screen
When using the analog terminal, use CTRL + Left and right arrows to skip one word at a time
Command history:
Bash automatically logs commands that were executed in the past and caches them in memory.
View command history: Historical
-C: Empty command history
-D + offset N m: delete m characters starting from nth command, M defaults to 1
-W: Save command history to history file
When the user exits normally, the in-memory command history is saved to the bash files in the user's home directory
This is a hidden file, the number of historical commands that bash history saves is limited and defaults to 1000
Histsize: An environment variable that represents the command history buffer size
The use of command history tips:
!n: The nth command displayed and executed
!-n: Executes the last nth command in the command history
!! : Executes the last command executed
! + "": The most recent command in the command history that starts with the specified string
!$: Referencing the last parameter of the previous command
Command completion
Under the command path, the given string can uniquely represent the command, and pressing the TAB key automatically complements the command
If it is not a unique representation, press the TAB key twice to list all the commands that begin with the string.
Path completion and command completion are similar
Command aliases:
Alias: Setting Command aliases
Alias NAME = COMMAND [option], which is equivalent to assigning a value to a variable.
Valid only in the current Shell declaration cycle
Alias: View the command aliases that have been defined
Ualias: Cancels a command alias that has already been defined
If you add a command alias to the same name as a command, the command that is represented by the alias is run under the shell, as
If you want to use the original command, use/command to indicate the command itself
Command substitution:
Replaces a subcommand in a command with the result of its execution.
Representation:
Command $ (subcommand)
Command ' Word commands ' Note that here is an anti-quote instead of a single quotation mark.
Quotes supported by bash:
' Anti-quote, for command substitution
"" Double quotes, weak references, can implement variable substitution
' single quote, strong reference, cannot implement variable substitution
File Distribution: globbing
* Used to represent any string of any length, including 0 for any length
? Used to represent any single character
[] matches any single string within any specified range
[: Space:] indicates a blank symbol
[:p unct:] denotes punctuation
[: Lower:] indicates lowercase letters
[: Upper:] denotes uppercase
[: Alpha:] denotes all uppercase and lowercase letters
[:d Igit:] indicates a number
[: Alnum:] denotes numbers and letters
[^] means matching a single character outside any specified range
Simple use of Linux bash