Centos7命令使用

在這裏插入圖片描述

systemctl start nginx.service #啓動nginx服務
systemctl enable nginx.service #設置開機自啓動
systemctl disable nginx.service #停止開機自啓動
systemctl status nginx.service #查看服務當前狀態
systemctl restart nginx.service  #重新啓動服務
systemctl list-units --type=service #查看所有已啓動的服務

啓動一個服務:systemctl start firewalld.service

關閉一個服務:systemctl stop firewalld.service

重啓一個服務:systemctl restart firewalld.service

顯示一個服務的狀態:systemctl status firewalld.service

Centos7關閉Selinux:
[root@node1 openvpn]# getenforce
Permissive
[root@node1 openvpn]# setenforce 0
[root@node1 openvpn]# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config
[root@node1 openvpn]# grep SELINUX=disabled /etc/selinux/config
下載常用命令:
yum install -y net-tools vim lrzsz wget tree screen lsof tcpdump

檢查memcached端口是否開啓?
telnet 172.16.1.21 11211
nc 172.16.1.21 11211
ss -lntup|grep memcached
netstat -lntup|grep memcached
lsof -i:11211
nmap -p11211 172.16.1.21
nmap -p80,443 172.16.1.0/24 10.0.0.0/24

ps -ef 查看進程(process)信息
ps aux 顯示更詳細的信息
預備姿勢: 虛擬內存=物理內存+swap
vsz virtual size 進程佔用了多少 虛擬內存
Rss 進程佔用了多少物理內存

更改主機名:
hostnamectl set-hostname oldboy
bash 生效

從Centos7開始默認使用firewall防火牆了
換成iptables防火牆,操作步驟如下:
1、關閉firewalld防火牆,關閉開機自啓
systemctl stop firewalld.service
systemctl disable firewalld.service
2、安裝iptables防火牆,設置開機自啓
yum -y install iptables-services net-tools
systemctl enable iptables.service
3、然後編輯iptables防火牆規則就好了
vim /etc/sysconfig/iptables
4、來個示例:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Centos同步網絡時間方法:
ntpdate只能用udp協議來同步時間,rdate支持用tcp協議或udp協議同步時間。
使用ntpdate更新時間
yum -y install ntpdate
/usr/sbin/ntpdate ntp1.aliyun.com
使用rdate更新時間
yum -y install rdate
查看時間rdate time-b.nist.gov
TCP方式更新服務器時間:rdate -s time-b.nist.gov或rdate -s time.nist.gov
UDP方式更新服務器時間:rdate -u time-b.nist.gov或rdate -u time.nist.gov

Centos7默認是沒有vim命令的只有vi
vim 命令下載:
rpm -qa|grep vim
yum -y install vim-enhanced vim*

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章