1、編寫指令碼disk.sh,顯示當前硬碟分割槽中空間利用率最大的值
[root@centos8 ~]# cat desk.sh#! /bin /bash
echo `df|grep '^/dev/sda'|tr -s " "| cut -d " " -f5| sort -nr| head -1`
[root@centos8 ~]# bash desk.sh
11%
2、編寫指令碼 systeminfo.sh,顯示當前主機系統資訊,包括:主機名,ipv4位址,作業系統版本,核心版本,cpu型號,記憶體大小,硬碟大小
[root@centos8 ~]# cat systeminfo.sh#! /bin/bash
echo -e "hostname :"`hostname`
echo -e "ipv4 address :"`ifconfig ens33 | grep -eo '([0-9].)[0-9]'| head -n1`
echo -e "os version :"`cat /etc/redhat-release`
echo -e "kernelversion :"`uname -r`
echo -e "cpu model :"`lscpu| grep '^model name'| tr -s ":"| cut -d ":" -f2`
echo -e "memery :"`free -h| grep '^mem'| tr -s " "| cut -d " " -f2`
echo -e "disk :"`lsblk| grep ^sda| tr -s " " | cut -d " " -f4`
[root@centos8 ~]# bash systeminfo.sh
hostname :centos8
ipv4 address :10.0.0.101
os version :centos linux release 8.4.2105
kernelversion :4.18.0-305.3.1.el8.x86_64
cpu model : 11th gen intel(r) core(tm) i5-1135g7 @ 2.40ghz
memery :1.9gi
disk :200g
3、20分鐘內通關vimtutor(可參考
已完成
shell指令碼練習
顯示系統資訊 bin bash descrition show system information echo os version is cat etc centos release echo kernel version is uname r echo cpu type lscpu grep m...
shell 指令碼練習
bin bash echo hello world chmod x test.sh 使指令碼具有執行許可權 test.sh 執行指令碼for file in ls etc 或for file in ls etc val expr 2 2 注意,這時的計算,2 2運算子和數字之間一定要加空格判斷字串是...
shell指令碼練習
1.簡單輸出指令碼 輸出 hello 王子 我們先建立指令碼檔案 touch lian.sh 這裡指令碼的檔案需要以。sh結尾 結果 2.通過位置變數建立系統賬號或密碼 結果 3.每週 5 使用 tar 命令備份 var log 下的所有日誌檔案 vim root logbak.sh 編寫備份指令碼...