Shell Learning Path: Shell Basics Daquan 1

Source: Internet
Author: User

Http://note.youdao.com/share/?id=a9d02257b639c94323c818bc38423919&type=notealias Command Alias:http://note.youdao.com/share/?id=cbcbd1156ab1f0835c4f76131dbf98e2&type=noteView Current User history commands History:http://note.youdao.com/share/?id=e878f9ed7bb7e8849fa57b67dc1eb7f3&type=noteadd a new hard disk and partition: Http://note.youdao.com/share/?id=8cf27602cdce36e1d4160f00e9004b00&type=noteDD if= input file of= output file bs= number of bytes count= options: if= input file Specify source file or source device of= output file specify destination file or target device ba= bytes Specify the number of bytes of input/output at one time. Make a data block count= number specify the number of input/output data block example: [[email protected]]# date; DD If=/dev/zero of=/root/testfile bs=1k count=100000; Date can be viewed by command execution before and after the date time Difference Example 2: We can use this command for data pair test or burn disk [[email protected]]# date; DD If=/dev/cdrom Of=/data/centos6.4-one.iso; Date, so I can do it. CD-ROM burn to/data/for later use and build local Yum source Pipe break: The correct output of command 1 as the operand of command 2 [[Email protected]]# ls | grep Fengtaotao requires that the command in front of the pipe character must have output [[Email protected]]# ll-a | Morp display the output of the ll-a if the command 1 must have the correct output Netstat-an View the function of the netstat command is to display network connections, routing tables, and network interface information to let users know which network connections are in operation.   [1] When used without parameters, Netstat displays the active TCP connection. Example: View a few remote connections on the current server [[Email protected]]# Netstat-an | grep "Established" Of course we can just count lines [Email protected]]# netstat-an | grep "established" | Wc-l

grep command:

[[email protected]] #grep [options] ' search content ' file name option:-I: Case-insensitive-N: Show line number-V: Reverse lookup--color=auto: Receive keyword display color Wildcard characters:
Wildcard characters Role
? Match an arbitrary character
* Match 0 or any number of characters, that is, any content can be matched
[] Matches any one of the characters in the brackets. For example [ABCD] represents any one of the matching ABCD
[-] Match any one of the characters in the brackets-representing ranges such as [a-z][a-z][0-9] and so on
[^] Logical non, which means that the match is not a character in brackets, for example [^0-9] represents a character that is not a number
‘‘ Single quotes, in single quotes all special characters will be used as text for example: $ @ * etc
"" Special symbols in double quotes have no meaning, but for $ \ ' Exception call variable values, apply commands, go to symbols, etc.
Anti-Quote Same as the following $ () For example: Echo ' ls ' or echo $ (LS) output is the LS command result
$()
# In Linux, # is commented as long as the # begins with an invalid comment
$ The value used to invoke the variable, if the value of the variable name is to be called, needs to use the definition of the $name variable Name=user1
\ A transfer character precedes a special meaning symbol and loses its special meaning \ $name is not a variable
Variables: Linux has 1, user-defined variables, 2, environment variables, 3, positional parameter variables, 4, predefined variables user-defined variables: variable definition: [[email protected]] #name =user1 [[email protected]] #ha ha=$ (DATE) variable overlay: [[email protected]] #name = "$name" 222 [[email protected]] #echo $name user1222 or using name=$ {name}222 View variables as above: We can use set to view variables (all variables in Set view system include custom variables) [[Email protected]]# set | grep namename=user1222 unload Variable unset name Environment variables: Setting environment variables: Export variable name = variable value you can use the Pstree command to view the process structure PS1 to modify the delimiter [[Email protected]]# settings Pre-defined variables:
Pre-defined variables Role
$? The return status of the last command executed, if the value of this variable is 0, indicates that the previous command was executed correctly; If the returned value is not 0 proof that no successful execution, the specific return value can be Baidu query return error code
$$ Process number (PID) of the current process
$! Process number (PID) of the last process running in the background
Receive keyboard input: read [options] [variable name] option:-P "prompt message": Output prompt when waiting for read input-t number of seconds: the Read command waits for user input and executes the default-n character number after the number of seconds after the-t option is used: REA The D command accepts only the specified number of characters and executes-S: The data entered by Silver City, suitable for confidential information such as passwords BASH operator: Declare declaring variable type [[email protected]] #declare [+/-][options] Variable name option:-: Set type attribute to variable +: Type attribute of the Cancel variable-i: Declare the variable as an integer Type-x: Declare a variable as an environment variable (or export variable)-P: shows an example of a declared type that makes a variable: [[email protected]] #aa = 11; bb=22; Declare-i cc= $aa + $bb && Echo $cc 33 The most common way is cc=$ (($aa + $bb)) in the operation we just use the external $ (()) Double parenthesis Inside the algorithm is the same as the mathematical formula algorithm for example: [email Protected]] #aa =$ (((11+3) *3/2) && Echo $aa 21 until the result is 21 and logic with && logic or | | Variable substitution method This table is similar to the ternary operator in PHP: for example: [Email protected]]# Environment variables: (environment variable allowed) environment variables are generally uppercase environment variable profile: 1.source command: [[email protected]] #source configuration file or.    The configuration file allows him to take effect immediately invalid restart/ETC/PROFILE/ETC/PROFILE.D/*.SH/ETC/BASHRC the environment variable profile for the above three paths is valid for all users ~/.bash_profile ~/.BASHRC profile environment variables for the current user when the environment profile for the above two paths is in effect Flowchart: Logoff Environment Profile: ~/.bash_logout default is empty history command profile: ~/.bash_history Shell Login Information: Post-logon information: Valid for both local and remote:/ETC/MOTD default is empty can add [[email protected]] #echo "AAA" >>/etc/motd[[email protected] "#exit [email Protected]] #从新登录后就有了本地终端登录信息:/etc/issue Remote terminal logon information:

Shell Learning Path: Shell Basics Daquan 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.