linux6和7主机名的修改及防火墙的关闭

linux6系统修改主机名:

用户必须为root或者具有root权限

ifconfig或者ip addr查看ip

1 [root@localhost ~]# vi /etc/sysconfig/network
内容修改如下:
NETWORKING=yes
HOSTNAME=master

centos7的主机名称修改:
hostnamectl set-hostname  主机名

2 [root@localhost ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
ip hostname

note:不要修改原内容,后面追加写入保存就ok

服务器或者网路重新启动

[root@localhost ~]# reboot
[root@localhost ~]# service network restart
重新登录后查看对应的hostname

1 centos7 查看防火墙状态
centos7防火墙默认firewalld,如果需要用iptables则需要安装
#先检查是否安装了iptables
service iptables status
#安装iptables
yum install -y iptables
#升级iptables
yum update iptables 
#安装iptables-services
yum install iptables-services
systemctl enable iptables.service
#开启服务
systemctl start iptables.service
#查看状态
systemctl status iptables.service

在CentOS7.4中,系统已经默认安装了firewalld,我们只需要安装firewall-config
[root@lvxinghao ~]# yum install firewalld firewall-config
[root@lvxinghao ~]# yum -y install firewall-config
[root@lvxinghao ~]# yum -y update firewalld

[root@lvxinghao ~]# systemctl status firewalld


关闭防火墙命令:systemctl stop firewalld.service

开启防火墙:systemctl start firewalld.service

关闭开机自启动:systemctl disable firewalld.service

开启开机启动:systemctl enable firewalld.service

防火墙状态查看:systemctl status firewalld

查看开机是否启动防火墙服务: systemctl is-enabled firewalld

禁用防火墙(系统启动时不启动防火墙服务):systemctl disable firewalld  


永久有效开启和关闭:

开启: chkconfig iptables on 

关闭: chkconfig iptables off

防火墙状态查看:/etc/init.d/iptables status

防火墙临时关闭:/etc/init.d/iptables stop

 

 

你可能感兴趣的:(hadoop,大数据,Linux)