Command Completion : tab
The shell program receives a request from the user to execute the command, and when the analysis is complete, the leftmost string is treated as a command
command lookup mechanism :
To find internal commands :
according to directory set in PATH environment variable, from left to right, search for file name under directory
The given heading character, if it can uniquely identify a command file program, directly complements the
given a heading character, if a command file program cannot be uniquely identified , thelist is given at a time tab
Path Completion : Tab
Under the given starting path, match each file in the path with the start string under the corresponding path.
if it can be uniquely identified, the direct completion
Otherwise, tab again , give the list
Double click Tab:
/2tab Show All directories below the root directory, including hidden directories
./2tab current directory subdirectories, including hidden directories
*2tab current directory subdirectories, excluding hidden directories
~2tab List of all users
$2tab All variables
@2tab/etc/hosts Record (CentOS7 not supported)
=2tab equivalent to ls –A (CentOS7 not supported)
mkdir: Create a new directory
Mkdir-p: automatically create parent directories on Demand
-V: Show detailed procedures
-M: directly given permissions
Note : The path base name is the action object of the command, and the path before the base name must exist
RmDir: Deleting a directory
Rmdir-p: When a directory is deleted, if its parent directory is empty, it is deleted
-V: Display procedure
Command line expansion :
~: automatically expands to the user's home directory, or the specified user's home directory
{}: Can host a comma-delimited list of paths and be able to expand multiple paths
For example:/tmp/{a,b} is equivalent to /tmp/a/tmp/b
execution status result of the command :
Bash outputs secondary results with status return values
Success : 0
failed : 1-255
after the command execution completes, its status return value is saved in bash 's special variable $? in
References :
Strong quote : '
Weak reference : ""
Command Reference : '
Bash shortcut keys :
Ctrl + L clear screen, equivalent to clear command
Ctrl + C abort command
Ctrl + S lock screen
Ctrl + q unlock
Ctrl + a cursor moves to the beginning of the command, which is equivalent to Home
Ctrl + e cursor moves to the end of the command line, equivalent to end
Ctrl + u Delete from cursor to beginning of command
Ctrl + k Remove from cursor to end of command line
CP Command : Copy
single Source copy : CP [OPTION] ... [-T] SOURCE DEST
if DEST does not exist : The file is created in advance and the data stream of the source file is copied to DEST
if DEST exists :
if DEST file : Overwrite destination file
if DEST Directory file : first Create a file with the same name as the source file in the DEST directory and copy its data stream
Multi-source replication : CP [OPTION] ... SOURCE ... DIRECTORY
if DEST does not exist : Error
if DEST exists :
if DEST Non-directory file : Error
if DEST is a directory file : Copy each file to the directory separately and keep the original
CP [OPTION] ...-t DIRECTORY SOURCE ...
Common Options :
-I: interactive replication, that is, before overwriting to remind users to confirm
-F: force overwrite target file
-r: Recursive copy directory
Historical: command-line history
command history is typically recorded in a . bash_history file, with the default record of
The history in the current shell is recorded in memory and will only be saved in . Bash_history after exiting.
-C: empty command History
-D Offset: Delete the specified offset command in history
N: Show recent nth history
-A: append the newly executed command history list to the history file for this session
-N: read unread rows to History list in history file
-r: read History file attached to History list
-W: Save History list to specified history file
-P: expands the history parameter into multiple lines, but does not exist in the history list
-S: expands the history parameter into a row, appended to the history list
Histsize Modify history Storage Bar Number
Histfile Specifies the location of the history file, the default is ~/.bash_history
Histfilesize the number of storage bars for the command that specifies the history file
histtimeformat= "%F%T" shows the specific execution time of each command
Histignore= "STR1:STR2" blocks certain command-sensitive strings from being displayed
control the command history mode :
Environment variables: Histcontrol
Ignoredups Default, ignore duplicate commands, continuous and same as "repeat"
Ignorespace ignores all commands that start with a blank
Ignoreboth equivalent to Ignoredups, Ignorespace 's combination
Erasedups Delete duplicate commands
!n: executes the History command historical output corresponding to the ordinal n command
!n: executes the last nth command in history
Some of the basic features of bash on Linux: