Before giving you a detailed introduction to the Linux Bash command, let's first understand the Bash command, and then give a comprehensive introduction to the Linux Bash command, hoping to be useful to you. You can edit events in the historical event list on the command line. Table 10-3 lists the operations performed to query the historical event list.
Table 10-3Linux Bash command query history event operations
Ctrl + n or move the cursor down to the next historical event of the current event in the history event list
Ctrl + p or move the cursor up to the previous historical event of the current event in the history event list
Esc <move to the beginning of the history event list table
Esc> move to the end of the historical event list table
! Event_num uses the historical event number to locate a historical event.
! Characters uses the character prefix of historical events to query a historical event.
!? Pattern uses the "pattern" to query events in the historical event list
! -Event_num: locates historical events by offset
Configure history: HISTFILE and HISTSIZE
The number of historical events saved by the system is stored in a specific system variable, which is HISTSIZE. The default value of this variable is usually set to 500. This value can be modified. For example, $ HISTSIZE = 10 reset the value of HISTSIZE to 10.
Historical events are saved in a file. The file name is specified by the HISTFILE variable. The default name of this file is. bash_history. You can assign a value to the variable HISTFILE to specify a new file name.
$ Echo $ HISTFILE
/Home/lisa/. bash_history
$ HISTFILE = "/home/lisa/newhist"
$ Echo $ HISTFILE
/Home/lisa/newhist
The preceding operations first display the value of the variable HISTFILE, and then assign it the new value "/home/lisa/newhist". All historical events will be saved in the newhist file in the future. Another way to make work easier is to use command aliases. The command alias is usually abbreviated to other commands to reduce keyboard input.
Command Format: alias [alias-name = 'ininal-command']
Alias-name is the alias used by the user for Linux Bash commands, and original-command is the original Bash commands and parameters. Note that the Linux Bash command recognizes the original command by space or press Enter. If quotes are not used, the Linux Bash command may intercept the first word, in this case, an error occurs. If no parameters are used after the alias command, the alias Linux Bash command and Its alias are displayed. The alias for the command is always valid during this logon. If you need an alias to be valid upon every login, write the alias command to the initialization script file.
If you often need to enter the following Linux Bash command, it is best to create an alias for it to reduce the workload.
$ Cd/usr/X11/lib/X11
If you create an alias named goconfig for this long command, enter the following command at the Linux Bash Command Prompt:
$ Alias goconfig = 'CD/usr/X11/lib/x11'
Now, unless you exit Bash, typing goconfig will have the same effect as the original long command. To cancel an alias, run the following command:
$ Unalias goconfig
These are some aliases that many people think are useful. They can be written into the initialization script file to improve work efficiency:
Alias ll = 'LS-l'
Alias log = 'logout'
Alias ls = 'LS-F'
If you are a DOS user and are used to doscommands, you can use the following alias to define Linux Bash commands as DOS:
Alias dir = 'LS'
Alias copy = 'cp'
Alias rename = 'mmv'
Alias md = 'mkdir'
Alias rd = 'rmdir'
Note: When defining an alias, there cannot be spaces on both sides of the equal sign. Otherwise, shell cannot decide what to do. Quotation marks are required only when Linux Bash commands contain spaces or special characters. If you type an alias command without any parameters, all defined aliases are displayed.
- Analyze svn commands from Linux
- Linux memory management methods
- Why does Microsoft envy Linux system security?
- Parsing Linux OS modification time
- Comprehensive parsing of Linux Make rules