Some of the orders to be used in 2016/7/3 are recorded here, to be continued ...
2016/7/4 More ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View IP Address: windows:ipconfig/all
Linux:ifconfig
Ifdown disable the NIC;
Ifup enable Nic;
Netstat: Query network status;
-T lists the TCP protocol ports;
-U lists UDP protocol ports;
-N does not use domain names and service names. Instead, use the IP address and port number
-l lists only network services in the listening state
-A Lists all network connections
-tuln what ports are open and what services are opened
-an which link to me all, also can see the related socket program
Netstat-an | grep estlabish |wc-l
Netstat-rn shows the routing list, you can see the gateway
Route-n View Gateway
Temporary Settings Gateway
Route add default GW 192.168.1.1
Route del default GW
In a server, intranet network card can not be set gateway
Nslookup translation domain name corresponding to IP
Restart Services Service Network REStat
Nslookup >server
View DNS
Ping sends ICMP packets,
Windows Ping4 time termination;
Linux has been ping.
Some websites prohibit ping to prevent exposing information.
Ping x.x.x.x-c Times
Telnet remote administration and Port probe command
SSH is encrypted and more secure
Telnet does not need to be managed remotely, port detection is possible
Telnet x.x.x.x without port is remote management, request far
Process Management machine opened Telnet service.
After adding the port, enter if there is information to indicate the other computer
If you do not open Telnet service, if you do not open the firewall to screen the port, if there is no prompt information, you can connect.
Exit Ctrl +] Exit
In Win and Linux are consistent.
TRACEROUTE Routing Tracking Command
-N Use IP not to use domain name faster
ICMP protocol, if the ping cannot see the passing node.
Download Command wget Package
Both FTP protocols and Telnet are plaintext delivery, file transfer protocols, Port 21, and their insecurity.
Tcpdump-i ETH0-NNX Port 21
-I-specified NIC interface;
-nn the domain name and service in the packet to IP and port
-X Displays the contents of the packet in 16-in and ASCII code
PORT specifies which ports to listen on
Grab Bag command
HTTP protocol is not encrypted, it is plaintext under Linux
The HTTPS protocol is encrypted.
SSH protocol
Xshell Tools (Remote administration Tools)
WINSCP Tool (File Transfer tool)
Symmetric encryption Algorithm (single key): Encryption decryption a secret;
Compression tool can be encrypted while compressing
Asymmetric encryption algorithm
The password generates the public and private keys.
Who wants to see who to let the public key encryption, using their own public key and want to let the people see the public key encryption, protect the sender of the password security with the password and the private key to decrypt
SSH Security Shell Protocol
Ensure the security of the data transfer process, but if it is stolen before it is delivered, it will not be able to.
Remote administration specifies a Linux server
SSH User name @ip
User name does not write is logged in with the currently logged-on user;
Whether to download the public key Yes
Exit back to Local
Ls-a
Show hidden files
. It starts with a hidden file.
Download files
SCP [-R] Username @ip: File path Local Path
Uploading files
SCP [-r] Local file username @ip: Upload path
Upload file does not need to add-r, upload directory to add-R
SECURECRT (surcharge)
Xshell remote management of Linux tools
WINSCP is a tool that Windows passes data to a Linux computer, and the background protocol is the SSH encryption protocol.
SFTP protocol
Application Run State Monitoring script
Leveraging client Script
Mysqp,ab,mongo,php,jstack
Nginxstatus,nagio-libexec
Service-side interface support
The regular expression of shell programming
A is a matching string that matches a condition in a file, and a wildcard character is used to match a qualifying file name.
A positive is a match, the output contains an entire row of the corresponding character, the wildcard is an exact match, and the corresponding character is output. Commands for search strings grep, awk, sed, and other commands support regular expressions; search file commands ls, find, CP do not support regular expressions, wildcard characters are supported.
Base Regular
* The previous character repeats 0 times to several times, * the front plus 1 characters does not work, you must add one before
e.g.
grep * Test.txt
Matches 0 or more characters of a.
grep aa* Test.txt
Match at least one character of a
. matches any character other than a line break
S.. D matches between S and D must have two arbitrary characters
. * Match All content
^ Match beginning of line, $ match end of row
grep ^s Test.txt
Match rows with s as the beginning of the line
grep a$ Test.txt
Match a line with a as the end of a line
^$ Matching blank line
[] matches any one of the characters specified in the brackets, matching only one character
e.g.
S[ao]id
Match S and I, if not a, but O's character
[0-9]
Match any one number
^[] represents the line with the characters inside the brackets as the beginning of the row
In brackets in the ^ represents the inverse
[^a-z] matches lines that do not start with lowercase letters
^[^A-ZA-Z]
Match a line that doesn't start with a letter
Linux can not be directly A-Z, should be a-za-z
\ escape character, which makes the special symbol lose its function
\.$ a line that matches the end of a.
. $ match All rows
\{n\} indicates that the preceding character appears n times
But the positive is the inclusion of the match, so the actual match is at least n times
e.g.
A\{3\} matches a string that appears 3 consecutive times
[0-9]\{3\}
Matches a string that contains a continuous number of three digits
\{n,\} indicates that the preceding character appears to be no less than n times
e.g.
^[0-9]\{3,\}[A-Z]
Match a line that starts with a minimum of three consecutive digits
Need to add a delimiter to match more precisely
e.g.
grep "Xc\{3\}u" test.txt
Practise more and practise more
\{n,m\} indicates that the preceding character appears at least n times and appears at most m times
e.g.
Sa\{1,3\}i
Match the previous character a appears once to 3 times, to add both sides of the delimiter to be effective
Vim empties, emptying from the cursor line to the end of the line
D J
Match IP Address
The following is a matching IP from the document and cannot write the correct IP address because IP is 0-255
grep [0-9]\{1,3\}\. [0-9]\{1,3\}\. [0-9]\{1-3\}\ "Test.txt
Character Interception command
Cut [option] file name
-F Column Number: Extract the first few columns,
-D Separator: Splits columns According to the specified delimiter. The default delimiter is tab, plus-D when you need to set the
Cut-f 2,4 Student.txt Extract 2 and 4 columns
The limitations of cut
df-h | Cut-f 1,3
The df-h separator is a space, not the cut default tab. When the separator is not found, the separator is considered to be the last.
Interception of comparative law of the file is better, when using inconsistent number of spaces as a separator, cut halo.
More simple
printf ' output format ' output
"Can not be omitted
Format output%ns output string, n is a number representing the output of several characters,%ni output integer, n is a number of digits to output several digits;
%M.NF output floating-point number, 8.2f indicates a total output of 8 digits, where 2 bits are decimals, 6 bits are integers.
\a Output Warning tone
\b Output Backspace key, is the BACKSPACE key
\f Clear Screen
\ n Line Change
\ r Enter, is the ENTER key
\ t horizontal output backspace key, is the TAB key
\v Vertical output Backspace key, is the TAB key
To identify only the original command, you need to write out the format
Data flow not supported, grep.
Awk
Print and printf commands are supported in the awk output.
Print automatically adds a newline character after each output, and Linux defaults to no Print command.
printf is a standard format output command, does not automatically add line breaks, need to wrap, and manually add line breaks. Don't know Echo.
Get the data you need in the file
awk ' Condition 1{action 1} Condition 2{action 2} ... ' Filename
No conditions to represent unconditional execution
A relational expression is a condition; an action is typically a formatted output and a Process Control statement.
The printf escape character must be enclosed in double quotes.
e.g.
awk ' {printf $ ' t ' $ ' \ n '} ' Student.txt
awk ' {print $ ' \ t ' $} ' Student.txt
The difference between printf and print, and print automatically lines line breaks at the end
BEGIN End
Fs= ":"
Built-in variable that represents who the separator is
You must add begin when you specify a separator manually
awk ' begin{fs= ': "}{print $" \ T "$}" Student.txt
Sed
Character Substitution command
Format
sed [option] ' [Action] ' filename
Options
-N: The general sed command will output the data to the screen, plus-n will only output the lines that are processed by the SED command to the screen
-e: Allows multiple sed command edits to be applied to the input data, separated by multiple commands;
-I: Modify the read file directly with the result of the SED, not the screen output
Action
-A: Append, add one or more lines after the current line
-C: Line substitution, with C followed by a string to replace the original data row
-I: Inserts one or more rows before the current line.
-D: Delete, delete the specified line
-P: Print, output the specified line
-S: Character substitution, replacing another string with a string. The format is "row range s/old string/new string/g" and the replacement format in Vim is similar
/g indicates that multiple substitutions within the specified range are replaced without replacing one.
Sed ' 2,4d ' student.txt
Indicates deletion of 2 to 4 rows
Character processing commands
Sort sorting command
Options
-F: Ignore case
-N: Sort by numeric value, using string sorting by default
-R: Reverse Sort
-T: Specifies a separator character, which defaults to a tab character
-K N[,m]: Specifies the field range sort, starting with the nth field and ending with the M field.
WC statistic Command
wc[option] File name
Options
-L: Count rows only
-W: Count only words
-M: Only count characters