大数据学习之Linux基础(二)

一、Linux高级配置

  1. 配置静态IP

    • 配置文件地址:/etc/sysconfig/network-scripts/ifcfg-ens33

    • 修改内容:

      • BOOTPROTO值由“dhcp”修改为:static

      • 增加:【值的设置参考VMware虚拟网络编辑器内容】

        • IPADDR
        • GATEWAY
        • DNS1

    在这里插入图片描述
    在这里插入图片描述

  2. 设置主机名

    1. 临时设置:立即生效

      • 命令:hostname 主机名
      [root@localhost ~]# hostname bigdata01
      [root@localhost ~]# hostname
      bigdata01
      
    2. 永久设置:重启后生效

      • 修改配置文件:/etc/hostname
  3. 关闭防火墙

    1. 临时关闭

      • 命令:systemctl stop firewalld

        [root@bigdata01 ~]# systemctl stop firewalld
        [root@bigdata01 ~]# systemctl status firewalld
        ● firewalld.service - firewalld - dynamic firewall daemon
           Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
           Active: inactive (dead) since Wed 2022-02-23 23:25:08 CST; 8s ago
             Docs: man:firewalld(1)
          Process: 710 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
         Main PID: 710 (code=exited, status=0/SUCCESS)
        
        Feb 23 23:14:53 bigdata01 systemd[1]: Starting firewalld - dynamic firewall daemon...
        Feb 23 23:14:54 bigdata01 systemd[1]: Started firewalld - dynamic firewall daemon.
        Feb 23 23:25:08 bigdata01 systemd[1]: Stopping firewalld - dynamic firewall daemon...
        Feb 23 23:25:08 bigdata01 systemd[1]: Stopped firewalld - dynamic firewall daemon.
        
    2. 永久关闭

      • 命令:systemctl disable firewalld

        [root@bigdata01 ~]# systemctl disable firewalld
        Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
        Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
        =========================================查看开机启动项===================================================
        [root@bigdata01 ~]# systemctl list-unit-files | grep firewalld
        firewalld.service                             disabled
        

二、shell编程

  1. ​ 基本规则:

    • 扩展名:建议以.sh为扩展名

    • 脚本第一行内容为:#!/bin/bash

    • 除第一行外,其他以#开头的行为注释

    • 执行命令:

      • bash filename 或 sh filename:可直接执行shell脚本,无需为其添加执行权限【原因:将脚本作为参数传入bash或sh命令】
      • 路径/filename:需为脚本添加执行权限后才能执行
      • filename:需将当前路径添加至环境变量才能执行【也需添加执行权限】
      ====================创建目录存放shell脚本===================================
      [root@bigdata01 ~]# mkdir shell
      [root@bigdata01 ~]# cd shell
      ====================创建hello.sh脚本=================================
      [root@bigdata01 shell]# vi hello.sh
      ====================脚本内容==============================
      #!/bin/bash
      #first command
      echo "hello world!"
      ~                                                                                                                         ====================脚本结束==============================                                                 
                                                                                                                               ====================使用bash命令执行脚本==============================
      [root@bigdata01 shell]# bash hello.sh 
      hello world!
      ================
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值