# soft link
cd /usr/local/bin
ln -fs /usr/local/mysql/bin/mysql mysq || ln -fs /usr/local/mysql/bin/mysql /usr/local/bin/mysql
# 建立全局可執行指令
echo 1 >> run
chmod + x run
ln -s {absolutePath}/run /usr/local/bin/{defineName}
find {path} -name {filename}
cat /etc/*release*
grep text -r folder |grep xx |grep xx // regex text
# centos 7 up use firewall default
# 檢視防火牆狀态
firewall-cmd --state
firewall-cmd --reload #重新開機firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
systemctl stop firewalld.service
systemctl start firewalld.service
# forbidden auto start when computer start
systemctl disable firewalld.service
# 檢視 firewall 已開放端口
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent
指令含義:
–zone #作用域
–add-port=80/tcp #添加端口,格式為:端口/通訊協定
–permanent #永久生效,沒有此參數重新開機後失效
# Iptable 防火牆服務需要自己安裝
yum install iptables-services
systemctl start iptables.service
systemctl status iptables.service
# 增加開放端口
vi /etc/sysconfig/iptables
# 增加規則
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
systemctl restart iptables.service #重新開機防火牆使配置生效
systemctl enable iptables.service #設定防火牆開機啟動
最後重新開機系統使設定生效即可。
systemctl start iptables.service #打開防火牆
systemctl stop iptables.service #關閉防火牆
service systemctl 指令詳解
systemd 是 Linux 下的一款系統和服務管理器, 檢視和控制systemd的主要指令是systemctl。
systemctl 控制單元時,通常須要使用單元檔案的全名,包括擴充名(比如 sshd.service)
馬上激活單元:
systemctl start <單元>
馬上停止單元:
# systemctl stop <單元>
重新啟動單元:
# systemctl restart <單元>
又一次載入配置:
# systemctl reload <單元>
輸出單元執行狀态:
# 很好用的指令 輸出 mysql, iptables 等狀态
$ systemctl status <單元>
# 禁用一個單元(禁用後,間接啟動也是不可能的):
systemctl mask <單元>
# 取消禁用
systemctl unmask <單元>
service 對比 systemctl
1.service指令
service指令其實是去/etc/init.d目錄下,去執行相關程式
service指令啟動redis腳本
service redis start
直接啟動redis腳本
/etc/init.d/redis start
開機自啟動
update-rc.d redis defaults
其中腳本需要我們自己編寫
2.systemctl指令
systemd是Linux系統最新的初始化系統(init),作用是提高系統的啟動速度,盡可能啟動較少的程序,盡可能更多程序并發啟動。
systemd對應的程序管理指令是systemctl
1)systemctl指令相容了service
即systemctl也會去/etc/init.d目錄下,檢視,執行相關程式