网站首页 安全运维 CentOS 7 常用方法
service network restart
systemctl restart network
2、systemctl相关启动一个服务:systemctl start nginx.service
关闭一个服务:systemctl stop postfix.service
重启一个服务:systemctl restart nginx.service
显示一个服务的状态:systemctl status postfix.service
在开机时启用一个服务:systemctl enable nginx.service
在开机时禁用一个服务:systemctl disable nginx.service
查看服务是否开机启动:systemctl is-enabled nginx.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
cat /etc/resolv.conf
设置主机和IP绑定信息:cat /etc/hosts
设置主机名:cat /etc/hostname
4、修改文件夹权限
查看防火墙状态:systemctl status firewalld.service
关闭:systemctl stop firewalld
开启:systemctl start firewalld
开机自动关闭:systemctl disable firewalld
开机自动启动:systemctl enable firewalld
查看开机是否启动:chkconfig --list|grep network(RHLE6)
临时关闭:
[root@localhost etc]#getenforce Enforcing
[root@localhost etc]#setenforce 0 setenforce:SELinux is disabled
永久关闭:
vim /etc/selinux/config # 将SELINUX=enforce改成SELINUX=disabled # 保存,重启
查看系统端口
netstat -anp |grep 端口号
查看进程
ps -aux | grep nginx
3. kill 命令用于终止进程
例如: kill -9 [PID]
-9 表示强迫进程立即停止
通常用 ps 查看进程 PID ,用 kill 命令终止进程
关闭全部进程
killall nginx