1、統計出/etc/passwd文件中其默認shell爲非/sbin/nologin的用戶個數,並將用戶都顯示出來
[root@centos6 ~]#cat /etc/passwd |grep -c nologin
30
2、查出用戶UID最大值的用戶名、UID及shell類型
[root@centos7 ~]#cat /etc/passwd |sort -nr -t: -k3 |cut -d: -f1,3,7 |head -1
nfsnobody:65534:/sbin/nologin
3、統計當前連接本機的每個遠程主機IP的連接數,並按從大到小排序
[root@centos6 ~]#ss -nt | grep ESTAB |tr -s " " : |cut -d: -f6 |sort |uniq -c|sort -nr
6 192.168.43.1
3 192.168.43.107
[root@centos7 ~]#ss -nt | sed -nr '/^ESTAB/s@.*[[:space:]]+([0-9.]+):[0-9]+.*@\1@p' | sort |uniq -c | sort -nr
6 192.168.43.1
2 192.168.43.128
4、編寫腳本 createuser.sh,實現如下功能:使用一個用戶名做爲參數,如果 指定參數的用戶存在,就顯示其存在,否則添加之;顯示添加的用戶的id號等 信息
#!/bin/bash
PASSWD=123456
if [ -z "$1" ];then
echo "請輸入一個需要創建的用戶名!"
elif `id $1 &> /dev/null`;then
echo "用戶已經存在!"
else
useradd $1 &> /dev/null
echo $PASSWD |passwd --stdin $1 &> /dev/null
echo $user 已創建
echo UID是`id -u $1`
echo passwd是${PASSWD}
exit
fi
5、編寫生成腳本基本格式的腳本,包括作者,聯繫方式,版本,時間,描述等
vim ~/.vimrc 寫入一下內容
set ai
set ignorecase
set tabstop=2
set cursorline
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#********************************************************************")
call setline(4,"#Author: wangyan")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(9,"#Description: The test script")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G
架構班小夥伴看這裏:
1、安裝配置redis的cluster集羣
2、安裝配置memcached高可用
3、安裝vmware esxi