Shell Basics (1)

Source: Internet
Author: User

Shell Basics
1.shell is the intermediate medium used when the system interacts with the computer hardware, and he is a system tool. If the computer hardware analogy to the human "body", the system kernel is the human "brain", the shell is the "five senses".
2. Record command history
When you exit the shell normally, the command currently run by the shell is saved to the. Bash_hiseory: Record up to 1000 commands
(1) "!!": Two consecutive executions of the previous instruction
(2) "!n": N represents a number, executes nth instruction
(3) "! Character section": Example of a command that starts with "PW"
3. Command and File Completion tab
4. Command alias: Aliases are typically used for commands
Usage #alias Modify name = ' command name ' to create an alias
#unalias modify name to de-alias

5. Special symbols: Wildcard use " "Match 0 or more characters, with"? "Matches one character
Usage: #ls-D Xiaojunjun

6. Special symbols: pipe symbol "|" He is the input of the last instruction as the output of the previous instruction
7. Job Control: (1) Ctrl + Z: Pause can use FG N recovery, N for number
(2) Ctrl + C: Terminate task
(3) Enter jobs to see the paused task
(4) If you want to put the pause task back in the background, you can use the BG command, or FG to run directly
(5) View the name of the PID #ps aux |grep Running
Terminate Kall

8. Variables: General variables are uppercase

9. Order env: Can detect all the variables of the system
HOSTNAME: Host Type
Shell:shell type
Histsize: Number of historical records
MALL: Mail Storage directory
PATH: This variable determines which directories the shell will look for commands and programs
PWD: Current directory
LANG: Language Environment Volume
Home: Current Home Directory
LOGNAME: User Login Name
10. Command set: Similar to env, you can not only display system variables, but also customize variables

Variable cannot be used after single new shell
You can use bash: Create a new shell

(1) Allow all users in the system to log in and use the variable
Vi/etc/profile adding "Export myname=aming" to run Source/etc/profile
(2) Only the current user is allowed to use
Vi./BASHRC Add "Export myname=aming" to run source./BASHRC

Custom variable Rules
(1) Set Variable format "A=b" where a variable name, b variable content, the equal sign cannot have spaces on either side
(2) Variable names can only consist of letters, numbers, and underscores, and cannot begin with a number
(3) When the variable has a special symbol (such as: space) need to add a single quotation mark
#myname = ' aming LI '
(4) Double quotation marks when the contents of the variable are enclosed in single quotation marks
#myname = "Aming S"
(5) Variable contents need to use the command when using the anti-quote
#myname = pwd
Note: The anti-quote is 1 built next to that, press down on OK
Add double quotation marks to variable contents plus other variable contents

11. Command bash: You can enter a shell that is the child shell of the original shell

12. Command Pstree: Will indicate that all processes of the Linux system are displayed in a tree-shaped structure
13. Command export: command declaration, in child shell, variable can also be displayed

12. Command unset: Cancel variable

20180604

Shell Basics (1)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.