2022-01-23

1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来

[root@sakura:]~ # cat /etc/passwd | grep '/sbin/nologin' |wc -l
17
[root@sakura:]~ # cat /etc/passwd | grep '/sbin/nologin' |cut -d: -f1
bin
daemon
adm
lp
mail
operator
games
ftp
nobody
dbus
systemd-coredump
systemd-resolve
tss
polkitd
unbound
sssd
sshd

2、查出用户UID最大值的用户名、UID及shell类型

[root@sakura:]~ # cat /etc/passwd | cut -d: -f1,3,7 | sort -t: -k2 -n | tail -n 1
nobody:65534:/sbin/nologin

3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序

[root@sakura:]~ # w -h | wc -l
3
[root@sakura:]~ # w -h | tr -s ' ' | cut -d' ' -f3 | uniq | sort -nr
10.0.0.6
10.0.0.1

4、编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值

  #**********************************************
  # File Name: disk.sh
  # Author: sakurachen
  # mail: 1084795138@qq.com
  # Created Time: Sun 23 Jan 2022 12:37:51 PM CST
  #**********************************************
  #!/bin/bash
 
  df | grep '/dev/nv*' | grep -Eo '[0-9]+%' | sort -nr | head -1

[root@sakura:]/data # bash disk.sh
10%

5、编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小

#**********************************************
# File Name: systeminfo.sh
# Author: sakurachen
# mail: 1084795138@qq.com
# Created Time: Sun 23 Jan 2022 01:21:55 PM CST
#**********************************************
#!/bin/bash
colorbegin="\e[1;34m"
colorend="\e[0m"

echo -e "主机名: $colorbegin `hostname` $colorend"
echo -e "IPV4 address: $colorbegin `ip a show eth0 | grep -Eo '([0-9]{1,3}.){3}[0-9]{1,3}' | head -1` $colorend"
# echo -e "IPV4 address: $colorbegin `ip a | grep 'eth0' | sed -n '2p' | awk '{print $2}'` $colorend"
echo -e "操作系统版本: $colorbegin `cat /etc/redhat-release` $colorend"
echo -e "内核版本: $colorbegin `uname -r` $colorend"
echo -e "cpu信号: $colorbegin `lscpu | grep -i '^Model name:' | tr -s ' '|cut -d: -f2` $colorend"
echo -e "内存大小: $colorbegin `free  -h | grep Mem | tr -s ' ' | cut -d' ' -f2` $colorend"
#echo -e "内存大小: $colorbegin `cat /proc/meminfo | grep 'MemTotal' | tr -s ' '|cut -d: -f2` $colorend"
echo -e "硬盘大小: $colorbegin `lsblk| grep -E '^nv' | grep -Eo [0-9]+[[:upper:]]` $colorend"
image.png

6、20分钟内通关vimtutor(可参考https://yyqing.me/post/2017/2017-02-22-vimtutor-chinese-summary

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 本章内容 ◆ 编程基础◆ 脚本基本格式◆ 变量◆ 运算◆ 条件测试◆ 条件判断if◆ 条件判断case◆ 配置用户...
    Liang_JC阅读 224评论 0 0
  • 1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来...
    普离阿莫阅读 96评论 0 0
  • 1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin得用户个数,并将用户都显示出来...
    也许是你的幽默我不懂阅读 175评论 0 0
  • 1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来...
    如是我闻_17e6阅读 159评论 0 0
  • 1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来...
    newjourney阅读 197评论 0 0