zoukankan      html  css  js  c++  java
  • 第三周作业

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

      [09:03:59 root@centos8 ~]#echo -e  "一共`grep -v  "/sbin/nologin" /etc/passwd  |awk  -F: '{ print $1 }'|wc -l`个,它们分别是:
      `grep -v  "/sbin/nologin" /etc/passwd  |awk  -F: '{ print $1 }'`"
      一共5个,它们分别是:
      root
      sync
      shutdown
      halt
      tan
    2. 查出用户UID最大值的用户名、UID及shell类型

      [09:08:01 root@centos8 ~]#cat /etc/passwd  |cut -d: -f1,3,7|sort -t: -k2 -n |tail -n1
      nobody:65534:/sbin/nologin
    3. 统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序

      [09:15:09 root@centos8 ~]#w -h |tr -s " " |cut -d" " -f3|uniq -c |sort -nr
           3 10.0.0.1
           1 -
    4. 编写脚本disk.sh,显示当前硬盘分区中空间利用率最大的值

      [09:28:03 root@centos8 ~]#cat disk.sh
      #!/bin/bash

      #================================================================
      #   Copyright (C) 2021 IEucd Inc. All rights reserved.
      #
      #   文件名称:disk.sh
      #   创 建 者:TanLiang
      #   创建日期:2021年09月20日
      #   描   述:This is a test file
      #
      #================================================================

      df -h |grep -v ^Filesystem |tr -s " " |cut -d" "  -f5,6|sort -nr|head -n 1
      [09:28:13 root@centos8 ~]#bash disk.sh
      21% /boot
    5. 编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小


      [10:03:38 root@centos8 ~]#cat systeminfo.sh
      #!/bin/bash

      #================================================================
      #   Copyright (C) 2021 IEucd Inc. All rights reserved.
      #
      #   文件名称:systeminfo.sh
      #   创 建 者:TanLiang
      #   创建日期:2021年09月20日
      #   描   述:This is a test file
      #
      #================================================================

      echo -e "1.主机名:e[31m`hostname`e[0m"
      echo -e "2:ipv4地址:e[31m`ip a |grep eth0 |grep inet |tr -s " " |cut -d" " -f3|cut -d/ -f1`e[0m"
      echo -e "3.操作系统版本:e[31m`hostnamectl |awk -F: 'NR==7{print $2}'`e[0m"
      echo -e "4.内核版本:e[31m`uname -r`e[0m"
      echo -e "5.cpu型号:e[31m`lscpu|awk 'NR==13{print $0}'|cut -d: -f2|tr -s " "`e[0m"
      echo -e "6.内存大小:e[31m`free -mh|grep Mem |tr -s " "|cut -d" " -f2`e[0m"
      echo -e "7.硬盘大小: e[31m`df -h |grep sda|awk '{print $1," ",$2," ",$6}'`e[0m"
      [10:03:50 root@centos8 ~]#bash systeminfo.sh
      1.主机名:centos8.magedu.org
      2:ipv4地址:10.0.0.150
      3.操作系统版本: CentOS Linux 8
      4.内核版本:4.18.0-240.el8.x86_64
      5.cpu型号: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
      6.内存大小:1.9Gi
      7.硬盘大小:
      /dev/sda5       100G   /
      /dev/sda2       50G     /date
      /dev/sda1       976M   /boot
    6. 20分钟内通关vimtutor(可参考https://yyqing.me/post/2017/2017-02-22-vimtutor-chinese-summary

    [10:06:43 root@centos8 ~]#vimtutor zh
  • 相关阅读:
    tcp/ip_properties_file
    tcp_ip/udp
    笔记1
    css样式使用_css
    常用的html标签总结_html
    利用sqlalchemy(ORM框架)连接操作mysql_mysql
    mysql基础命令_mysql
    redis使用_python
    RabitMQ使用_python
    后台管理页面2种常用模板_html
  • 原文地址:https://www.cnblogs.com/tanll/p/15313833.html
Copyright © 2011-2022 走看看