# 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目錄下,查看,執行相關程序