一、Linux高级配置
-
配置静态IP
-
配置文件地址:/etc/sysconfig/network-scripts/ifcfg-ens33
-
修改内容:
-
BOOTPROTO值由“dhcp”修改为:static
-
增加:【值的设置参考VMware虚拟网络编辑器内容】
- IPADDR
- GATEWAY
- DNS1
-
-
-
设置主机名
-
临时设置:立即生效
- 命令:hostname 主机名
[root@localhost ~]# hostname bigdata01 [root@localhost ~]# hostname bigdata01
-
永久设置:重启后生效
- 修改配置文件:/etc/hostname
-
-
关闭防火墙
-
临时关闭
-
命令: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.
-
-
永久关闭
-
命令: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编程
-
基本规则:
-
扩展名:建议以.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! ================
-