第三周(0906~0913)
2021/9/14 6:05:12
本文主要是介绍第三周(0906~0913),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
第三周 作业 1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来cat /etc/passwd |grep -v‘/sbin/nologin’|wc -l cat /etc/passwd |grep -v‘/sbin/nologin’|cut -d: -f12、查出用户UID最大值的用户名、UID及shell类型
grep -E `cat /etc/passwd |cut -d: -f3|sort -nr|head -1` /etc/passwd
ss -nta|grep ESTAB|awk -F" " '{print $NF}'|sed s#::ffff:##g |awk -F":" '{print $1}'|sort|uniq -c|sort -rn
4、编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值
df |grep -E '^/dev/sd'|grep -oE '([0-9]+)%' |tr -d '%'|sort -nr|head -1
[root@centos7 ~]# vim test.sh #!/bin/bash # This is a shell script for print system infomations. COLOR_B="\e[0;33m" COLOR_E="\e[0m" echo "-------------------------------------system infomation------------------------------------" echo -e "Hostname is ${COLOR_B}`hostname`$COLOR_E" echo -e "IPv4 address is ${COLOR_B}`ifconfig ens33 |grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|head -n1`$COLOR_E" echo -e "OS version is ${COLOR_B}`cat /etc/redhat-release`$COLOR_E" echo -e "Kernel version is ${COLOR_B}`uname -r`$COLOR_E" echo -e "CPU info is ${COLOR_B}`lscpu|grep "Model name" |cut -d: -f2 |tr -s " "`$COLOR_E" echo -e "MEM is ${COLOR_B}`cat /proc/meminfo |head -n1 |grep -Eo '[0-9]+.*'`$COLOR_E" echo -e "Disk space is ${COLOR_B}`lsblk |grep -E 'sd[ab]+\>'|awk -F" " 'BEGIN{ORS=" "}{print $1,$4}'`$COLOR_E" ~
![](/upload/202109/14/202109140605124155.png)
这篇关于第三周(0906~0913)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-07-04TiDB 资源管控的对撞测试以及最佳实践架构
- 2024-07-03万字长文聊聊Web3的组成架构
- 2024-07-02springboot项目无法注册到nacos-icode9专业技术文章分享
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现