#/bin/sh Indirect modification of ports
#auther: Qiruyi
#date: 2016-08-05
#system: centos6.5
#version: 1.0
#require ROOT to run this script. Using the root user
if [["$ (whoami)" = "root"]];
Then echo, "Root is run"
Else
echo "Please su root to run this script"
Fi
\cp/etc/ssh/sshd_config/etc/ssh/sshd_config.$ (date + "%F"-$RANDOM)
Sed-i ' s% #Port 22%port 22% '/etc/ssh/sshd_config
Sed-i-E '/port 22/a\port 1222 '/etc/ssh/sshd_config//Append one port 1222
#sed ' 3a-a input-p tcp-m tcp--dport 80-j ACCEPT '-i/etc/sysconfig/iptables//Append one port 1222
/etc/rc.d/init.d/sshd restart
If [' Lsof-i tcp:1222 |wc-l '-eq 3];
Then
echo "SSH modified Port succeeded"
Sed-i ' s%port 22% #Port 22% '/etc/ssh/sshd_config
Else
echo "SSH modified port unsuccessful"
Fi
#保证安全, after viewing/etc/ssh/sshd_config manual restart after/etc/rc.d/init.d/sshd restart takes effect
Anti-Quote "'
The usage of this thing, I Baidu a bit, and $ () is the same. When executing a command, the statement in the ", or $ () is executed once as a command, and the result is added to the original command for re-execution
In addition, the differences from the online excerpt are as follows:
A, () just re-open a sub-shell for a sequence of commands to execute
b,{} Executes a string of commands in the current shell
C, () and {} All put a string of commands inside the parentheses, and the commands are separated by a number;
D, () The last command can be used without a semicolon
e,{} The last command to use a semicolon
f,{} must have a space between the first command and the opening parenthesis
G, each command in () does not have to have spaces in parentheses
H, () and the redirection of a command inside the {} brackets only affects the command, but redirects outside the brackets affect all the commands in the parentheses
two brackets (()), which represent arithmetic expansions, are standard arithmetic calculations for what they include-note that floating-point numbers cannot be counted, and if a floating-point number is required, it needs to be done in BC.
As for the brackets [], the sensory function is used to compare. For example, in the IF statement inside, while statement inside, and so on.
this leads to the [..] and [[...]] The difference: (from an online, measured confirmation): use [[...]] The conditional judgment structure, rather than [...], can prevent many logic errors in the script. For example, &&, | |, <, and > operators can normally exist in [[]] conditional judgment structures, but if they appear in the [] structure, they will get an error.
Modify CentOS Default 22-Port Footstep