Linux修改机器名、防火墙设置,开关机命令

修改机器名

  1. 说明:
    [hadoop@localhost Desktop]
    @之前的hadoop为用户名
    @之后的localhost为机器名,也可以理解为IP映射地址
  2. 进入到【/etc】下的hosts文件,修改IP与主机名的映射关系【注意:要在root用户下修改】
    追加:192.168.253.20 spark
    在这里插入图片描述
  3. 修改【/etc/sysconfig/network】文件 【注意:机器名不能含有“_”下划线】
    修改HOSTNAME属性为:spark
    HOSTNME=spark
    在这里插入图片描述
  4. 重启系统,即可!
    $>reboot
    在这里插入图片描述
  5. 修改【C:\Windows\System32\drivers\etc】下的hosts文件
    如果无hosts文件,则需手动创建hosts文件【如果遇到权限问题,最简便的方式是用Notepad++打开进行修改】
    添加:192.168.253.20 spark
    在主机直接ping虚拟机的机器名来通信:cmd>ping spark
    在这里插入图片描述
    在这里插入图片描述

防火墙设置

  1. 查看防火墙状态
    [root@spark Desktop]# service iptables status
  2. 临时关闭防火墙【要在root用户下
    [root@spark Desktop]# service iptables stop
    [root@spark Desktop]# service iptables status
    iptables: Firewall is not running.
  3. 查看防火墙开机启动状态
    [root@spark Desktop]# chkconfig iptables --list
    iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  4. 设置开机启动防火墙为关闭状态【root权限
    [root@spark Desktop]# chkconfig iptables off
    [root@spark Desktop]# chkconfig iptables --list
    iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  5. 设置开机启动防火墙为开启状态【root权限
    [root@spark Desktop]# chkconfig iptables on
    [root@spark Desktop]#chkconfig iptables --list
    iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Linux的开关机

  1. 基本语法
    (1)sync (功能描述:将数据由内存同步到硬盘中)
    (2)shutdown [选项] 时间
    选项:
    -h:关机
    -r:重启
    注意:shutdown命令要在root用户下使用
    (3)halt (功能描述:关闭系统,等同于shutdown -h now 和 poweroff)
    (4)reboot (功能描述:就是重启,等同于 shutdown -r now)
  2. 【案例】
    (1)将数据由内存同步到硬盘中
    [root@spark Desktop]# sync
    (2)计算机将在10分钟后关机,并且会显示在登录用户的当前屏幕中
    [root@spark Desktop]# shutdown -h 10 'shutdown after 10 mins张三'
    (3)立马关机
    [root@spark Desktop]# shutdown -h now
    (4)系统立马重启
    [root@spark Desktop]# shutdown -r now
    (5)重启(等同于:shutdown -r now)
    [root@spark Desktop]# reboot
    (6)关机(等同于:shutdown -h nowpoweroff)
    [root@spark Desktop]# halt
  3. 【注意】:不管是重启系统还是关闭系统,首先要运行sync命令,把内存中的数据写到磁盘中。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值