八、系统管理
八、系统管理
8.1 防火墙操作
1 service iptables status //查看iptables服务的状态 2 service iptables start //开启iptables服务 3 service iptables stop //停止iptables服务 4 service iptables restart //重启iptables服务 5 chkconfig iptables off //关闭iptables服务的开机自启动 6 chkconfig iptables on //开启iptables服务的开机自启动 7 ##centos7 防火墙操作 8 systemctl status firewalld.service //查看防火墙状态 9 systemctl stop firewalld.service //关闭运行的防火墙 10 systemctl disable firewalld.service //永久禁止防火墙服务
8.2 修改主机名(CentOS 7)
1 hostnamectl set-hostname 主机名
8.3 查看网络
1 ifconfig
8.4 修改IP
1 修改网络配置文件,文件地址:/etc/sysconfig/network-scripts/ifcfg-eth0 2 ------------------------------------------------ 3 主要修改以下配置: 4 TYPE=Ethernet //网络类型 5 BOOTPROTO=static //静态IP 6 DEVICE=ens00 //网卡名 7 IPADDR=192.168.1.100 //设置的IP 8 NETMASK=255.255.255.0 //子网掩码 9 GATEWAY=192.168.1.1 //网关 10 DNS1=192.168.1.1 //DNS 11 DNS2=8.8.8.8 //备用DNS 12 ONBOOT=yes //系统启动时启动此设置 13 ------------------------------------------------- 14 修改保存以后使用命令重启网卡:service network restart
8.5 配置映射
1 修改文件:vi /etc/hosts 2 在文件最后添加映射地址,示例如下: 3 192.168.1.101 node1 4 192.168.1.102 node2 5 192.168.1.103 node3 6 配置好以后保存退出,输入命令:ping node1 ,可见实际 ping 的是 192.168.1.101。
8.6 查看进程
1 ps -ef //查看所有正在运行的进程
8.7 结束进程
1 kill pid //杀死该pid的进程 2 kill -9 pid //强制杀死该进程
8.8 查看链接
1 ping IP //查看与此IP地址的连接情况 2 netstat -an //查看当前系统端口 3 netstat -an | grep 8080 //查看指定端口
8.9 快速清屏
1 ctrl+l //清屏,往上翻可以查看历史操作 2 clear //清屏
8.10 远程主机
1 ssh IP //远程主机,需要输入用户名和密码
8.11 查看历史命令
1 history //查看历史的输入命令