当前位置:网站首页>Shell_ 00_ First meeting shell
Shell_ 00_ First meeting shell
2022-07-06 16:50:00 【Coke loving w】
Shell_00_ First time to know Shell
Shell Basics
CLI(Command Line Interface): Command line interface
1)CLI Only accept text input , And only output text and basic graphics ;
2)Linux After system startup , Create by default in the system memory 5~6 individual CLI Terminal session running
// It can be done by Ctrl+Alt+(F2~F7) Switch ,F1 For graphical interface
Shell: Users and Linux Kernel interactive program ( be based on C Language writing )
| Shell species | explain |
|---|---|
| csh (C Shell) | Grammatical similarity C Language , Internal orders 52 individual At present, it is not used much , Has been /bin/tcsh replaced |
| Ksh (Korn Shell) | Grammatical similarity Bourne Shell, Internal orders 42 individual Have csh Easy to use features , be relative to bash A little restrictive |
| tcsh | Belong to csh Enhanced Edition , And csh Fully compatible with |
| sh | It belongs to shortcut Has been /bin/bash replaced |
| zch | Linux The largest in Shell, Internal orders 84 individual More complex to use , Rarely use this Shell |
| bash | CentOS By default, the system uses Shell |
1)bash The path of is :/bin/bash;
2) stay /etc/passwd The last field in each row is the user's default shell
Bash Shell
Bash(GNU Bourne-Again Shell): A number of Linux The default in the distribution Shell Interpreter
1) The following is from Shell Name instead of Bash Shell name ;
2)Bash Shell The essence is a program ( When running , It becomes a process )
Shell function
(1) Record historical orders (history)
1)“~/.bash_histroy” Record all commands executed by login ( Default 1000 individual );
2) The command executed by login is stored in memory , After logging off the system, the memory records it to ~/.bash_history file ;
3) The number of recorded commands can be modified HISTFILESIZE To increase / Reduce
history command : operation Shell The historical order in the book
Command format 1:histroy n
1)N Is the number , According to recent N Historical orders
2) If there is no N, Then all historical commands are displayed by default
Command format 2:history Options // Operate on historical commands
| Options | meaning |
|---|---|
| -c | Will the current Shell All in history Content removal |
| -a | Will add history Cache is written to ~/.bash_history In file |
| -r | take ~/.bash_history The contents of the document read history In cache |
| -w | The current history Cache is written to ~/.bash_history In file |
! command : Carry out section N History commands
Command format :!N
//!! Is to execute the last command
(2) command / File completion function (Tab)
1) Command only / Prefix of file name , adopt Tab Key can automatically complete ;
2) If there are multiple commands / The prefix of the file name is the same , Then list all specific names
(3) Command alias settings (alias)
1) To configure “~/.bashrc” File implementation command alias
alias command : Set alias command ( Temporary settings )
Command format :alias The alias command =‘ command Options ’
1) Direct input alias Then all alias commands are displayed
unalias command : Cancel command alias
Command format :unalias The alias command
(4) Programming script (shell scripts)
(5) task management 、 The front desk 、 Backstage control (job control、foreground、background)
(6) wildcard (Wilecard)
Father / Son Shell
Father Shell: Sign in CLI or GUI When running the terminal emulator in , Interaction started by default Shell
Son Shell: In the father Shell Under the environment of , New created by invoking the command Shell Program
1) Son Shell Only the father can inherit Shell The global environment variable of ;
bash command : establish / Callers Shell
Command format :bash Options
| Options | meaning |
|---|---|
| -c command | Callers Shell After executing the specified command , And return to the parent Shell |
| -i | Create a child Shell, And enter the sub Shell |
| -l | With login shell Form creation sub Shell, And enter the sub Shell |
| -r | Create a child Shell, And enter the sub Shell Dan Zi Shell Cannot switch directories |
exit command : sign out Shell
Command format :exit
1) if Shell Itself is a child Shell, Will return to the relative child Shell The father of Shell;
2) if Shell Itself is the highest level Shell, It will close Shell;
Such as : Callers Shell Execute the specified command 
Such as : Create a child Shell, And enter the sub Shell Then return to the father Shell
Such as : Create restricted child Shell
Built in command
External command ( File system commands ):Bash Shell Outside the program
1) Usually located in /bin、/usr/bin、/sbin or /usr/sbin in ;
3) Call external command , You need to specify the absolute path of the external command ;
2) When invoking an external command , By default, create a child Shell Run external commands ;
which command : Query the full path of the command according to the command name
Command format :which Options Command name
| Options | meaning |
|---|---|
| -a | Put all PATH The commands found in the directory are listed |
| -v | Display the version information of the command |
1) The essence is based on environmental variables (PATH) The path specified , Go to query the file name
2) There are no options , The first full path found is displayed by default
Such as : Inquire about ls The full path of the command 
Internal key command :Bash Shell Component part ( Compile into one )
1) The internal key command defaults to the parent Shell Run in ;
type command : Query whether the command is Bash shell Built in commands
Command format :type Options Command name
| Options | meaning |
|---|---|
| -a | take PATH In the path of variable definition All file paths containing the command name are listed ( Include alias) |
| -p | The command is an external command , Will display the full file path If it were not for external orders , Then no data is displayed |
| -t | Command attributes are represented by special fields |
1)type Commands are similar in nature which command : Find the execution file
2) The special field is :file( External command )、alias( Command alias )、builtin( Internal key command )
Common internal key commands are as follows :
| command | function |
|---|---|
| : | Extended parameter list , Perform the redirection operation |
| . | Read and execute the command in the specified file |
| alias | Specify the command definition alias |
| bg | Run the task in background mode |
| bind | Bind the keyboard sequence to a readline Function or macro |
| break | Exit loop |
| builtin | Execute specified Shell Built in command |
| caller | Returns the context of the active subfunction call |
| cd | Toggle directory |
| command | Execute the specified command , Don't make Shell lookup |
| compgen | Specify word generation possible completion matches |
| complete | Display the specified word completion process |
| compopt | Modify the completion options for the specified word |
| continue | Skip this cycle , So let's do the next loop |
| declare | Declare variables or variable types |
| dirs | List the current storage directory |
| disown | Delete the task specified in the task column |
| echo | Output the specified text to stdout |
| enable | Enable / Disable the specified built-in command |
| eval | Splice the specified parameters into one command , And implement |
| exec | Specify command substitution Shell process |
| exit | mandatory Shell Exit with the specified exit status code |
| export | Specify the variable as the environment variable |
| fc | Select a command from the history |
| fg | Transfer the task to the foreground to run |
| getopts | Analyze the specified positional parameters |
| hash | Query and record the full pathname of the specified command |
| help | List the help documents |
| history | Display the history of the command |
| jobs | Make a list of tasks |
| kill | To specify the PID The process signals |
| let | Calculates each parameter in a mathematical expression |
| local | Create a variable with limited scope in the function |
| logout | sign out Shell |
| mapfile | from stdin Read data row , And join the index data group |
| popd | Delete record from directory stack |
| printf | Displays text using a formatted string |
| pushd | Add a directory to the directory stack |
| pwd | Displays the path of the current working directory |
| read | from stdin Read a row of data , And assign it to the specified variable |
| readarray | from stdin Read data row , And put it into the index data group |
| readonly | from stdin Read a row of data , And assign it to a read-only variable |
| return | Force the function to exit with the specified value |
| set | Sets and displays the values and values of environment variables Shell attribute |
| shift | Move the position parameters in turn |
| shopt | open / Close control Shell Variable value for optional behavior |
| source | Read and execute the command in the specified file |
| suspend | Pause Shell Implementation , Until receipt SIGCONT The signal |
| test | Returns the exit status code based on the specified condition 0 or 1 |
| times | Displays the accumulated user and system time |
| trap | If the specified system signal is received , Then execute the specified command |
| type | Detect whether it is a built-in command |
| typeset | Declare variables or variable types |
| ulimit | Set the specified resource limit for system users |
| umask | Specify the default mask for document permissions |
| unalias | Delete the specified alias |
| unset | Delete the specified environment variable or Shell attribute |
| wait | Wait for the specified process to complete , And return the exit status code |
边栏推荐
- Research Report on market supply and demand and strategy of double drum magnetic separator industry in China
- [unsolved]7-14 calculation diagram
- Solr new core
- ByteDance new programmer's growth secret: those glittering treasures mentors
- 第三章 MapReduce框架原理
- 第7章 __consumer_offsets topic
- The most lost road I have ever walked through is the brain circuit of ByteDance programmers
- 我走过最迷的路,是字节跳动程序员的脑回路
- Solve the problem that intel12 generation core CPU single thread only runs on small cores
- CMake Error: Could not create named generator Visual Studio 16 2019解决方法
猜你喜欢

7-4 harmonic average

Chapter 5 detailed explanation of consumer groups

第7章 __consumer_offsets topic

FLV格式详解

Soft music -js find the number of times that character appears in the string - Feng Hao's blog

The most lost road I have ever walked through is the brain circuit of ByteDance programmers

Solve the single thread scheduling problem of intel12 generation core CPU (II)

Summary of game theory

JS encapsulates the method of array inversion -- Feng Hao's blog

图像处理一百题(11-20)
随机推荐
Research Report of desktop clinical chemical analyzer industry - market status analysis and development prospect prediction
LeetCode 1562. Find the latest group of size M
字节跳动多篇论文入选 CVPR 2021,精选干货都在这里了
(multiple methods, need to continue to see) 7-11 go deep into the tiger's Den
LeetCode 1558. Get the minimum number of function calls of the target array
~78 radial gradient
Soft music -js find the number of times that character appears in the string - Feng Hao's blog
Investigation report of bench type Brinell hardness tester industry - market status analysis and development prospect prediction
第6章 DataNode
Market trend report, technical innovation and market forecast of China's desktop capacitance meter
Error: case label `15 'not within a switch statement
~Introduction to form 80
~85 transition
Simply try the new amp model of deepfacelab (deepfake)
LeetCode 1641. Count the number of Lexicographic vowel strings
LeetCode 1636. Sort the array in ascending order by frequency
Solr new core
Ffmpeg command line use
Chapter 7__ consumer_ offsets topic
Solve the problem of intel12 generation core CPU [small core full, large core onlookers] (win11)