zoukankan      html  css  js  c++  java
  • 第四周

    ------------恢复内容开始------------

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

     awk -F: '{shells[$NF]++;if($NF == "/sbin/nogin"){print $1,$NF}}END{for(i in shells){print i,shells[i]}}' /etc/passwd

     

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

     getent passwd|sort -t: -k3 -rn|head -1|cut -d: -f1,3,7

     

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

     netstat -nt ls s

     

    4、编写脚本 createuser.sh,实现如下功能:使用一个用户名做为参数,如果 指定参数的用户存在,就显示其存在,否则添加之;显示添加的用户的id号等 信息

      1 #!/bin/bash
      2 #
      3 #********************************************************************
      4 #Author:          小汤圆
      5 #:     
      6 #Date:           2019-11-25
      7 #FileName:      createuser.sh
      8 #URL:              暂无
      9 #Description:     The test script
     10 #Copyright (C):   2019 All rights reserved
     11 #QQ Address        2382990774
     12 #**************************************************************
     13 useradd $1 &> /dev/null
     14 if [ $? -eq 0 ] ;then                                                                     
     15     echo "user $1 is created"
     16     id $1
     17 else
     18     echo "user exits already or no argument "
     19     fi
    ~            

     

    5、编写生成脚本基本格式的脚本,包括作者,联系方式,版本,时间,描述等
     1 set ignorecase
      2 set cursorline
      3 set autoindent
      4 autocmd BufNewFile *.sh exec ":call SetTitle()"
      5 func SetTitle()
      6     if expand("%:e") == 'sh'
      7     call setline(1,"#!/bin/bash")
      8     call setline(2,"#")
      9     call setline(3,"#********************************************************************")   
     10     call setline(4,"#Author:          小汤圆")
     11     call setline(5,"#:      ")
     12     call setline(6,"#Date:           ".strftime("%Y-%m-%d"))
     13     call setline(7,"#FileName:      ".expand("%"))
     14     call setline(8,"#URL:              暂无")
     15     call setline(9,"#Description:     The test script")
     16     call setline(10,"#Copyright (C):   ".strftime("%Y")." All rights reserved")
     17     call setline(11,"#QQ Address        2382990774")                                      
     18     call setline(12,"#**************************************************************")
     19     call setline(13,"")
     20     endif
     21 endfunc
     22 autocmd BufNewFile * normal G
    ~                                

    ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------- 博客均为个人笔记,无所追求,仅供参考~~~ QQ--2382990774
  • 相关阅读:
    Ural 1057. Amount of Degrees
    BZOJ 3517: 翻硬币
    BZOJ 4527: K-D-Sequence
    CTC联结时间分类算法(语音、文本识别)
    我小苏太狼又回来了.
    /*--------------分割线--------------*/
    /*--------------分割线--------------*/
    洛谷 P4149 [IOI2011]Race-树分治(点分治,不容斥版)+读入挂-树上求一条路径,权值和等于 K,且边的数量最小
    Codeforces 161.D. Distance in Tree-树分治(点分治,不容斥版)-树上距离为K的点对数量-蜜汁TLE (VK Cup 2012 Round 1)
    洛谷 P2634 [国家集训队]聪聪可可-树分治(点分治,容斥版) +读入挂+手动O2优化吸点氧才过。。。-树上路径为3的倍数的路径数量
  • 原文地址:https://www.cnblogs.com/alexlv/p/11929060.html
Copyright © 2011-2022 走看看