1.1. Shell Basics
Bash is a language interpreter that is compatible with Bourne Shell and executes commands that are read from standard input device files. BASH is the abbreviation for the Bournae-again shell. Bash is backwards compatible with the original UNIX sh shell and incorporates some useful Korn shell and C shell features. It has functional improvements over SH in both programming and interactive use. In addition, most of the SH scripts can be run directly by bash without modification.
The Linux environment consists of the following components:
Kernel-------------------The core of the Linux operating system Shell------------------provide an interactive environment for the user and the kernel Terminal emulator-------------allows the user to enter commands and to display the results of commands on the screen Linux Desktop and window manager--linux Desktop is a collection of various software applications, including File Manager, window manager, etc. |
files associated with the login shell
When the Linux system is running at 3 o'clock, the user can log on locally to the system console, or directly to a graphical interface when the system is running at level 5. In both cases, you will need to enter your user name and password when you log in. When the user logs on, bash will use the following initialization file and startup script:
/etc/profile------------------System-level initialization files that define environment variables that are called by the login shell to execute /ETC/BASH.BASHRC or/ETC/BASHRC----their file names vary according to different Linux distributions, and each interactive Shell's system-level startup script defines functions and aliases /etc/bash.logout--------------System-level logon Shell cleanup script when the login shell exits $HOME/.bash_profile, $HOME/.bash_login, $HOME/.profile--User personal initialization script, executed by a login shell call. Only one of these three scripts will be executed, and in this order, the first one that exists will be executed $HOME/.BASHRC each interactive shell startup script----------------User's personal $HOME/.bash_logout-----------User's personal login Shell cleanup script that executes when the login shell exits $HOME/.inputrc---------------User's own startup script used by ReadLine, which defines the keyboard mappings for handling certain situations |
Interactive logon reading order: (enter user information directly through the terminal login system)
/etc/profile--/etc/profile.d/*.sh--and ~/.bash_profile--~/.BASHRC--/ETC/BASHRC
Non-interactive login reading order: (Su, terminal of graphical interface, execute script)
~/.BASHRC--/ETC/BASHRC-/etc/profile.d/*.sh
1.2. Basic Techniques for Bash operation
(1) Cursor Jump:
CTRL + A: Skip to the beginning of the command Ctrl+e jump to the end of the command line Ctrl+u: Delete the cursor to the beginning of the command line CTRL+K: Delete the cursor to the end of the command line Ctrl+l: Clear Screen CTRL + Z: Send the current command to the background Ctrl+shift+c: Copy Ctrl+shift+v: Pasting |
(2) History: View a list of command histories
-C: Empty command history
-d [n]: Delete command at specified location
-W: Save the Command history to the history file
The commands in the buffer are saved to the. bash_history file when the shell exits
Command history-related environment variables:
Histsize: The number of commands that can be saved in the command history;
Histfile: command history file;
Histfilesize: The number of commands the command history file can hold;
Histcontrol: Control the generation of command history;
Ignoredups: Ignore record duplicate command, repeat the same command for consecutive;
Ignorespace: Do not log commands that begin with a blank character;
Ignoreboth: Both of the above characteristics;
(3) The use of command history skills:
!n: Executes the nth command in the command history;
!-n: Executes the reciprocal nth command in the command history;
!: Executes the previous command;
!string: The most recent command in the command history that starts with a specified string
!$: References the last parameter of the previous command (or ESC,. ALT +.);
(4) command aliases: aliases defined in the shell are valid only for the current shell life cycle.
Alias cmdalias= ' COMMAND [options] [arguments] '
(5) command substitution: $ (command) or ' command '
(6) File name pass: globbing
*: Any character of any length ?: any single character [^]: matches any single character outside the specified range of characters such as: [^0-9] []: matches any single character within the specified range [: Space:]: white space character [:p UNCT:]: Punctuation [: Lower:]: lowercase letters [: Upper:]: Uppercase [: Alpha:]: Uppercase and lowercase letters [:d igit:]: Number [: Alnum:]: Numbers and uppercase and lowercase letters |
This article is from the "Wind and Drift" blog, please be sure to keep this source http://yinsuifeng.blog.51cto.com/10173491/1941744
First, the Linux Shell Foundation