Linux教程

linux03

本文主要是介绍linux03,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

第三周
1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来
cat /etc/passwd|grep '/sbin/nologin$'|cut -d: -f1
2、查出用户UID最大值的用户名、UID及shell类型3
cat /etc/passwd|sort -t: -k3 -n|tail -n1|cut -d: -f1,3,7
3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序
netstat -t | grep ':ssh'|tr -s ' '|cut -d ' ' -f5|cut -d: -f1 | uniq -c|sort -rn
4、编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值
#!/bin/bash
# **********************************************************
# * Author : haozhen
# * Email : haozhenyes@163.com
# * Create time : 2021-12-05 14:01
# * Filename : disk2.sh
# * Description :
# **********************************************************
df |grep -E "(/dev/nv)|(/dev/nv)"|grep -oE "[0-9]{1,3}%"|sort -nr|head -n1
5、编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小
#!/bin/bash
# **********************************************************
# * Author : haozhen
# * Email : haozhenyes@163.com
# * Create time : 2021-12-05 14:21
# * Filename : systeminfo.sh
# * Description :
# **********************************************************
echo "主机名:`hostname`"
echo "IPV4地址:`ifconfig ens160|grep -oE \"([0-9]{1,3}\.){3}[0-9]{1,3}\"|head -n1`"
echo "操作系统版本:`cat /etc/redhat-release`"
echo "内核版本:`uname -r`"
echo "CPU型号:`lscpu|grep 'Model name'|tr -s ' '|cut -d : -f2`"
echo "内存大小:`free -h|grep Mem|tr -s ' ' : |cut -d : -f2`"
echo "硬盘大小:`lsblk |grep '^nv' |tr -s ' ' |cut -d " " -f4`"

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

这篇关于linux03的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!