当前位置: 首页 > news >正文

Linux 830 shell:expect,ss -ant ,while IFS=read -r line,

[root@samba caozx26]# scp /home/caozx26/pub root@192.168.235.3:~/
root@192.168.235.3's password:
/home/caozx26/pub: not a regular file
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载```![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/bfba06eeef7845c8a892499f77a31836.png)```bash
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO0uF9+65Vnab1xc+GXvH/YqTXXfohWcTdFPtkbCzKjRez0bDAiOU9uVesqfEfQbjqcQFcwqIdR4MTSX9F+hu6dZkaHuPhDaXG7JCIa4N+8jpWPtOaY+nD0QHgRVheORIgKZvMv2/kYF6e8ihxo7FIUsYb5qT6+uZRWTnJAAc0x+EJSXIlwCaUVe9Pqdn7UECmO7gAlYZAcYz20iGgymz94IUfQIQtPEp1pbPquywFCpGcnEiA+pCNFuKqSC7sjbBWawWUdOwtAxlesD/hWRmYyqUGCVVQ+HYeBZHD1DlqFHCx7PDcViFO5tNbzxpC0q+jAC1O7vK5ueYU4xpI3xa1 root@nfs.cn
spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub
root@192.168.235.3's password: [root@samba caozx26]# ls /home/caozx26/pub/
[root@samba caozx26]#

在这里插入图片描述
在这里插入图片描述

[root@samba caozx26]# ip2=192.168.235.23
[root@samba caozx26]# cat ip2 | cut -d "." -f1-3
cat: ip2: 没有那个文件或目录
[root@samba caozx26]# echo ip2 | cut -d "." -f1-3
ip2
[root@samba caozx26]# cat ip2
cat: ip2: 没有那个文件或目录
[root@samba caozx26]# ls ip2
ls: 无法访问ip2: 没有那个文件或目录
[root@samba caozx26]# echo "ip2"
ip2
[root@samba caozx26]# cat rsa.sh
read -p "please input:" ip2
ip3=$( echo "$ip2" | cut -d "." -f1-3 )
if [ "$ip3" != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./rsa.sh
please input:192.168.235.23
./rsa.sh:行11: spawn: 未找到命令
couldn't read file "{": no such file or directory
./rsa.sh:行13: yes/no: 没有那个文件或目录
./rsa.sh:行13: exp_continue: 未找到命令
./rsa.sh:行14: password: 未找到命令
./rsa.sh:行16: 未预期的符号 `}' 附近有语法错误
./rsa.sh:行16: `}'
[root@samba caozx26]#

在这里插入图片描述

[root@samba caozx26]# cat ping.sh
./rsa.sh
read -p "please input:" ip2
ip=$( echo "$ip2" | cut -d "." -f1-3 )
if [ $ip != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
scp /home/caozx26/pub/id_rsa.pub root@$ip2 /root/[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./ping.sh
bash: ./ping.sh: 权限不够
[root@samba caozx26]# chmod +x ping.sh
[root@samba caozx26]# ./ping.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password: spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub/
root@192.168.235.3's password:
id_rsa.pub                                     100%  393   292.4KB/s   00:00
please input:192.168.235.100
cp: 无法获取"root@192.168.235.100" 的文件状态(stat): 没有那个文件或目录
[root@samba caozx26]#

在这里插入图片描述
web服务连接个数

[caozx26@samba ~]$ cat wc.sh
#!/bin/bash
#count_http_80_stat
declare -A array1
states="netstat -an | grep -c ':80\|:443'"
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array[$j]}
done
[caozx26@samba ~]$ ./wc.sh
grep:
netstat:
-an:
./wc.sh:行11: :80\|:443: 语法错误: 期待操作数 (错误符号是 ":80\|:443"[caozx26@samba ~]$
[caozx26@samba ~]$ cat wc.sh
#!/bin/bash
#count_http_80_stat
declare -A array1
states=$(netstat -an | grep -c ':80\|:443')
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array[$j]}
done
[caozx26@samba ~]$ cat wc1.sh
#!/bin/bash
#count_http_80_state
declare -A array1
states=`ss -ant|grep 80|cut d' ' -f1`
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array1[$j]}
done
[caozx26@samba ~]$ chmod +x wc1.sh
[caozx26@samba ~]$ ./wc1.sh
cut: d : 没有那个文件或目录
[caozx26@samba ~]$ vim wc1.sh[已修改但尚未保存]
/bin/bash: q: 未找到命令Shell 已返回127请按 ENTER 或其它命令继续
[caozx26@samba ~]$ ./wc1.sh
LISTEN:1

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[caozx26@samba ~]$ states=`ss -ant|grep 80|cut -d' ' -f1`
[caozx26@samba ~]$ declare -A array1
[caozx26@samba ~]$ for i in $states
> do
> let array1[$i]++
> done
[caozx26@samba ~]$ echo array1
array1
[caozx26@samba ~]$ echo array1[$i]
array1[LISTEN]

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[caozx26@samba ~]$ uid=$( cat /etc/passwd |cut -d ":" -f3 )
[caozx26@samba ~]$ echo $uid
0 1 2 3 4 5 6 7 8 11 12 14 99 192 81 999 998 997 32 996 995 994 173 993 172 171 75 992 991 107 59 990 113 989 38 42 29 65534 988 74 70 89 72 1000 1001 1002 48 1003 1004 13 987 1005 10001 10002 10003 10004 10005 10006 10007 10008 10009 100010 100 101 102 103 104 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 111 112 114 115 116 10022 117 10023 118 10024 119 10025 1110 10026 1991 1992 1993 1994 1995 10027 10028 10029 10030 10031
[caozx26@samba ~]$ echo $uid
0 1 2 3 4 5 6 7 8 11 12 14 99 192 81 999 998 997 32 996 995 994 173 993 172 171 75 992 991 107 59 990 113 989 38 42 29 65534 988 74 70 89 72 1000 1001 1002 48 1003 1004 13 987 1005 10001 10002 10003 10004 10005 10006 10007 10008 10009 100010 100 101 102 103 104 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 111 112 114 115 116 10022 117 10023 118 10024 119 10025 1110 10026 1991 1992 1993 1994 1995 10027 10028 10029 10030 10031
[caozx26@samba ~]$ grep $uid="0" /etc/passwd
grep: 1: 没有那个文件或目录
grep: 2: 没有那个文件或目录
grep: 3: 没有那个文件或目录
grep: 4: 没有那个文件或目录
grep: 5: 没有那个文件或目录
grep: 6: 没有那个文件或目录
grep: 7: 没有那个文件或目录
grep: 8: 没有那个文件或目录
grep: 11: 没有那个文件或目录
grep: 12: 没有那个文件或目录
grep: 14: 没有那个文件或目录
grep: 99: 没有那个文件或目录
grep: 192: 没有那个文件或目录
grep: 81: 没有那个文件或目录
grep: 999: 没有那个文件或目录
grep: 998: 没有那个文件或目录
grep: 997: 没有那个文件或目录
grep: 32: 没有那个文件或目录
grep: 996: 没有那个文件或目录
grep: 995: 没有那个文件或目录
grep: 994: 没有那个文件或目录
grep: 173: 没有那个文件或目录
grep: 993: 没有那个文件或目录
grep: 172: 没有那个文件或目录
grep: 171: 没有那个文件或目录
grep: 75: 没有那个文件或目录
grep: 992: 没有那个文件或目录
grep: 991: 没有那个文件或目录
grep: 107: 没有那个文件或目录
grep: 59: 没有那个文件或目录
grep: 990: 没有那个文件或目录
grep: 113: 没有那个文件或目录
grep: 989: 没有那个文件或目录
grep: 38: 没有那个文件或目录
grep: 42: 没有那个文件或目录
grep: 29: 没有那个文件或目录
grep: 65534: 没有那个文件或目录
grep: 988: 没有那个文件或目录
grep: 74: 没有那个文件或目录
grep: 70: 没有那个文件或目录
grep: 89: 没有那个文件或目录
grep: 72: 没有那个文件或目录
grep: 1000: 没有那个文件或目录
grep: 1001: 没有那个文件或目录
grep: 1002: 没有那个文件或目录
grep: 48: 没有那个文件或目录
grep: 1003: 没有那个文件或目录
grep: 1004: 没有那个文件或目录
grep: 13: 没有那个文件或目录
grep: 987: 没有那个文件或目录
grep: 1005: 没有那个文件或目录
grep: 10001: 没有那个文件或目录
grep: 10002: 没有那个文件或目录
grep: 10003: 没有那个文件或目录
grep: 10004: 没有那个文件或目录
grep: 10005: 没有那个文件或目录
grep: 10006: 没有那个文件或目录
grep: 10007: 没有那个文件或目录
grep: 10008: 没有那个文件或目录
grep: 10009: 没有那个文件或目录
grep: 100010: 没有那个文件或目录
grep: 100: 没有那个文件或目录
grep: 101: 没有那个文件或目录
grep: 102: 没有那个文件或目录
grep: 103: 没有那个文件或目录
grep: 104: 没有那个文件或目录
grep: 10010: 没有那个文件或目录
grep: 10011: 没有那个文件或目录
grep: 10012: 没有那个文件或目录
grep: 10013: 没有那个文件或目录
grep: 10014: 没有那个文件或目录
grep: 10015: 没有那个文件或目录
grep: 10016: 没有那个文件或目录
grep: 10017: 没有那个文件或目录
grep: 10018: 没有那个文件或目录
grep: 10019: 没有那个文件或目录
grep: 10020: 没有那个文件或目录
grep: 10021: 没有那个文件或目录
grep: 111: 没有那个文件或目录
grep: 112: 没有那个文件或目录
grep: 114: 没有那个文件或目录
grep: 115: 没有那个文件或目录
grep: 116: 没有那个文件或目录
grep: 10022: 没有那个文件或目录
grep: 117: 没有那个文件或目录
grep: 10023: 没有那个文件或目录
grep: 118: 没有那个文件或目录
grep: 10024: 没有那个文件或目录
grep: 119: 没有那个文件或目录
grep: 10025: 没有那个文件或目录
grep: 1110: 没有那个文件或目录
grep: 10026: 没有那个文件或目录
grep: 1991: 没有那个文件或目录
grep: 1992: 没有那个文件或目录
grep: 1993: 没有那个文件或目录
grep: 1994: 没有那个文件或目录
grep: 1995: 没有那个文件或目录
grep: 10027: 没有那个文件或目录
grep: 10028: 没有那个文件或目录
grep: 10029: 没有那个文件或目录
grep: 10030: 没有那个文件或目录
grep: 10031=0: 没有那个文件或目录
/etc/passwd:root:x:0:0:root:/root:/bin/bash
/etc/passwd:sync:x:5:0:sync:/sbin:/bin/sync
/etc/passwd:shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
/etc/passwd:halt:x:7:0:halt:/sbin:/sbin/halt
/etc/passwd:operator:x:11:0:operator:/root:/sbin/nologin
/etc/passwd:games:x:12:100:games:/usr/games:/sbin/nologin
/etc/passwd:ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
/etc/passwd:setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
/etc/passwd:qemu:x:107:107:qemu user:/:/sbin/nologin
/etc/passwd:sssd:x:990:984:User for sssd:/:/sbin/nologin
/etc/passwd:avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
/etc/passwd:caozx26:x:1000:1000:caozx26:/home/caozx26:/bin/bash
/etc/passwd:code:x:1001:1001::/home/code:/bin/bash
/etc/passwd:rsync:x:1002:1002::/home/rsync:/sbin/nologin
/etc/passwd:user01:x:1003:1003::/home/user01:/bin/bash
/etc/passwd:u02:x:1004:1005::/home/u02:/bin/bash
/etc/passwd:u03:x:13:48::/home/u03:/bin/bash
/etc/passwd:stu5:x:1005:1006::/home/stu5:/bin/bash
/etc/passwd:stuu1:x:10001:10001::/home/stuu1:/bin/bash
/etc/passwd:stuu2:x:10002:10002::/home/stuu2:/bin/bash
/etc/passwd:stuu3:x:10003:10003::/home/stuu3:/bin/bash
/etc/passwd:stuu4:x:10004:10004::/home/stuu4:/bin/bash
/etc/passwd:stuu5:x:10005:10005::/home/stuu5:/bin/bash
/etc/passwd:stuu6:x:10006:10006::/home/stuu6:/bin/bash
/etc/passwd:stuu7:x:10007:10007::/home/stuu7:/bin/bash
/etc/passwd:stuu8:x:10008:10008::/home/stuu8:/bin/bash
/etc/passwd:stuu9:x:10009:10009::/home/stuu9:/bin/bash
/etc/passwd:stuu10:x:100010:10010::/home/stuu10:/bin/bash
/etc/passwd:stu0:x:100:10011::/home/stu0:/bin/bash
/etc/passwd:stu1:x:101:10012::/home/stu1:/bin/bash
/etc/passwd:stu2:x:102:10013::/home/stu2:/bin/bash
/etc/passwd:stu3:x:103:10014::/home/stu3:/bin/bash
/etc/passwd:stu4:x:104:10015::/home/stu4:/bin/bash
/etc/passwd:stt6:x:10010:10016::/rhome/stt6:/bin/bash
/etc/passwd:stt7:x:10011:10017::/rhome/stt7:/bin/bash
/etc/passwd:stt8:x:10012:10018::/rhome/stt8:/bin/bash
/etc/passwd:stt9:x:10013:10019::/rhome/stt9:/bin/bash
/etc/passwd:stt10:x:10014:10020::/rhome/stt10:/bin/bash
/etc/passwd:stt11:x:10015:10021::/rhome/stt11:/bin/bash
/etc/passwd:ss6:x:10016:10022::/rhome/ss6:/bin/bash
/etc/passwd:ss7:x:10017:10023::/rhome/ss7:/bin/bash
/etc/passwd:ss8:x:10018:10024:

在这里插入图片描述
在这里插入图片描述

[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
fi
done < "rf.txt"[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ grep ':0:' /etc/passwd
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
[caozx26@samba ~]$
[caozx26@samba ~]$ cat us.shgrep  /etc/passwd > user.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
else
if [ $uid -gt 0 ]&&[ $uid -lt 1000 ];then
echo "$line">systemctlu.txt
fi
fi
if [ $uid -ge 1000 ];then
echo "line">normaluser.txt
fi
done < "user.txt"[caozx26@samba ~]$ ./us.sh
c^C[caozx26@samba ~]$

在这里插入图片描述

shell

推送用户公钥

192.168.235.10
192.168.235.3 用户服务器

[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./ping.sh
bash: ./ping.sh: 权限不够
[root@samba caozx26]# chmod +x ping.sh
[root@samba caozx26]# ./ping.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password: spawn scp root@192.168.235.3:/root/.s /home/caozx26/pub/
root@192.168.235.3's password:
id_rsa.pub                                     100%  393   292.4KB/s
please input:192.168.235.100
cp: 无法获取"root@192.168.235.100" 的文件状态(stat): 没有那个文件或目
[root@samba caozx26]# vim ping.sh
[root@samba caozx26]# cat ping.sh
./rsa.sh
read -p "please input:" ip2
ip=$( echo "$ip2" | cut -d "." -f1-3 )
if [ $ip != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
scp /home/caozx26/pub/id_rsa.pub root@$ip2:/root/[root@samba caozx26]# ./ping.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password: spawn scp root@192.168.235.3:/root/.s /home/caozx26/pub/
root@192.168.235.3's password:
id_rsa.pub                                     100%  393   254.3KB/s
please input:192.168.235.100
id_rsa.pub                                     100%  393   246.3KB/s
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh   rsa.sh     utilc.sh  视频  下载
find.sh     l2  ntp1.sh     ping.sh  until1.sh  公共      图片  音乐
inotify.sh  ll  ntpdate.sh  pub      until.sh   模板      文档  桌面

192.168.235.100 (推送目标)

[root@backup ~]# ls
2010    aa3              file4.java  file9.java            rsync_jav
23.txt  anaconda-ks.cfg  file5.java  id_rsa.pub            shop
2.java  file1.java       file6.java  initial-setup-ks.cfg
aa1     file2.java       file7.java  linux.txt
aa2     file3.java       file8.java  q
[root@backup ~]# ls -l id_rsa.pub
-rw-r--r--. 1 root root 393 830 11:13 id_rsa.pub

计web服务的不同连接状态个数

[caozx26@samba ~]$ cat wc1.sh
#!/bin/bash
#count_http_80_state
declare -A array1
states=`ss -ant|grep 80|cut -d' ' -f1`
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array1[$j]}
done
[caozx26@samba ~]$ ./wc1.sh
LISTEN:1
[caozx26@samba ~]$ states=`ss -ant|grep 80|cut -d' ' -f1`
[caozx26@samba ~]$ declare -A array1
[caozx26@samba ~]$ for i in $states
> do
> let array1[$i]++
> done
[caozx26@samba ~]$ echo array1
array1
[caozx26@samba ~]$ echo array1[$i]
array1[LISTEN]
[caozx26@samba ~]$ echo $states
LISTEN
[caozx26@samba ~]$
[caozx26@samba ~]$ echo ${array1[@]}
1
[caozx26@samba ~]$ echo ${array1[$i]}
1
[caozx26@samba ~]$ echo ${!array1[@]}
LISTEN
[caozx26@samba ~]$ echo ${array1[listen]}[caozx26@samba ~]$ echo ${array1[LISTEN]}
1
[caozx26@samba ~]$ echo ${!array1[@]}
LISTEN
[caozx26@samba ~]$ for j in ${!array1[@]}
> do
> echo $j:${array1[$j]}
> done
LISTEN:1
[caozx26@samba ~]$ ./wc1.sh
LISTEN:1
[caozx26@samba ~]$  tail -5 /etc/passwd
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash

用户名分类,分为管理员用户,系统用户,普通用户

[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shcat  /etc/passwd > user.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
else
if [ $uid -gt 0 ]&&[ $uid -lt 1000 ];then
echo "$line">>systemctlu.txt
fi
fi
if [ $uid -ge 1000 ];then
echo "$line">>normaluser.txt
fi
done < "user.txt"[caozx26@samba ~]$ ./user.txt
-bash: ./user.txt: 权限不够
[caozx26@samba ~]$ ./user.sh
-bash: ./user.sh: 没有那个文件或目录
[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ cat normaluser.txt
dfs10:x:10031:10045::/rhome/19910:/bin/bash
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
caozx26:x:1000:1000:caozx26:/home/caozx26:/bin/bash
code:x:1001:1001::/home/code:/bin/bash

倒计时脚本,要求显示离2019年1月1日(元旦)的凌晨0点,还有多少天,多少时,多少分,多少秒。

[caozx26@samba ~]$ cat upt.sh
read -p "please input year:" y
read -p "please input month:" m
read -p "please input day:" d
year=$( date | cut -d " " -f1 )
month=$( date | cut -d " " -f2 )
day=$( date | cut -d " " -f3 )
ly=$(( $y - "$year" ))
if [ $ly -eq 1 ];else
ly=0
fi
lm=$(( "$m"-"$month" ))
if [ $lm -lt 0 ];then
lm=$(("$m"+12-"month"))
fi
ld=$(("$d"-"$day" ))
echo "距离$y$m$d还剩$ly year $lm month $ld day"
[caozx26@samba ~]$ chmod +x upt.sh
[caozx26@samba ~]$ ./upt.sh
please input year:2026
please input month:2
please input day:3
./upt.sh:行7: 2026 - "2025年" : 语法错误: 期待操作数 (错误符号是 ""2025" ")
./upt.sh:行8: 未预期的符号 `else' 附近有语法错误
./upt.sh:行8: `if [ $ly -eq 1 ];else'
[caozx26@samba ~]$

记录

    ┌───────────────────────────────────────────────────────────────────         ───┐│                 • MobaXterm Personal Edition v23.2 •                          ││               (SSH client, X server and network tools)                        ││                                                                               ││ ⮞ SSH session to code@192.168.235.10                                          ││   • Direct SSH      :  ✓                                                      ││   • SSH compression :  ✓                                                      ││   • SSH-browser     :  ✓                                                      ││   • X11-forwarding  :(remote display is forwarded through SSH         )  ││                                                                               ││ ⮞ For more info, ctrl+click on help or visit our website.                     │└───────────────────────────────────────────────────────────────────         ───┘Last login: Fri Aug 29 20:58:39 2025 from 192.168.235.1
[code@samba ~]$ su - caozx26
密码:
上一次登录:五 829 21:00:00 CST 2025pts/3 上
[caozx26@samba ~]$ sudo su
[sudo] caozx26 的密码:
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh     until.sh  模板  文档  桌面
find.sh     l2  ntp1.sh     rsa.sh     utilc.sh  视频  下载
inotify.sh  ll  ntpdate.sh  until1.sh  公共      图片  音乐
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO0uF9+65Vnab1xc+GXvH/YqTXXfohWcTd         FPtkbCzKjRez0bDAiOU9uVesqfEfQbjqcQFcwqIdR4MTSX9F+hu6dZkaHuPhDaXG7JCIa4N+         8jpWPtOaY+nD0QHgRVheORIgKZvMv2/kYF6e8ihxo7FIUsYb5qT6+uZRWTnJAAc0x+EJSXIl         wCaUVe9Pqdn7UECmO7gAlYZAcYz20iGgymz94IUfQIQtPEp1pbPquywFCpGcnEiA+pCNFuKq         SC7sjbBWawWUdOwtAxlesD/hWRmYyqUGCVVQ+HYeBZHD1DlqFHCx7PDcViFO5tNbzxpC0q+j         AC1O7vK5ueYU4xpI3xa1 root@nfs.cn
[root@samba caozx26]# scp
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file][-l limit] [-o ssh_option] [-P port] [-S program][[user@]host1:]file1 ... [[user@]host2:]file2
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh     until.sh  模板  文档  桌面
find.sh     l2  ntp1.sh     rsa.sh     utilc.sh  视频  下载
inotify.sh  ll  ntpdate.sh  until1.sh  公共      图片  音乐
[root@samba caozx26]# mkdir pub
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:~/.ssh/id_rsa.pub ~/pub
expect {"yes/no"}
[root@samba caozx26]# scp ~/pub root@192.168.235.3:~/
root@192.168.235.3's password:
/root/pub: No such file or directory
[root@samba caozx26]# pwd
/home/caozx26
[root@samba caozx26]# scp /home/caozx26/pub root@192.168.235.3:~/
root@192.168.235.3's password:
/home/caozx26/pub: not a regular file
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# scp -r /home/caozx26/pub root@192.168.235.3:~/
root@192.168.235.3's password:
[root@samba caozx26]# ssh root@192.168.235.3
root@192.168.235.3's password:
Last login: Sat Aug 30 08:27:00 2025 from 192.168.235.1
[root@nfs ~]# ls ~
1.txt            initial-setup-ks.cfg  inotify-tools-3.13.tar.gz  pub
anaconda-ks.cfg  inotify-tools-3.13    nfs.sh
[root@nfs ~]# exit
登出
Connection to 192.168.235.3 closed.
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:~/.ssh/id_rsa.pub ~/pub
expect {"yes/no"}
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:~/.ssh/id_rsa.pub ~/pub
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO0uF9+65Vnab1xc+GXvH/YqTXXfohWcTdFPtkbCzKjRez0bDAiOU9uVesqfEfQbjqcQFcwqIdR4MTSX9F+hu6dZkaHuPhDaXG7JCIa4N+8jpWPtOaY+nD0QHgRVheORIgKZvMv2/kYF6e8ihxo7FIUsYb5qT6+uZRWTnJAAc0x+EJSXIlwCaUVe9Pqdn7UECmO7gAlYZAcYz20iGgymz94IUfQIQtPEp1pbPquywFCpGcnEiA+pCNFuKqSC7sjbBWawWUdOwtAxlesD/hWRmYyqUGCVVQ+HYeBZHD1DlqFHCx7PDcViFO5tNbzxpC0q+jAC1O7vK5ueYU4xpI3xa1 root@nfs.cn
spawn scp root@192.168.235.3:~/.ssh/id_rsa.pub ~/pub
root@192.168.235.3's password: [root@samba caozx26]# ls ~/pub
ls: 无法访问/root/pub: 没有那个文件或目录
[root@samba caozx26]# ls ~/pub
ls: 无法访问/root/pub: 没有那个文件或目录
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# pwd
/home/caozx26
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:~/.ssh/id_rsa.pub /home/caozx26/pub
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO0uF9+65Vnab1xc+GXvH/YqTXXfohWcTdFPtkbCzKjRez0bDAiOU9uVesqfEfQbjqcQFcwqIdR4MTSX9F+hu6dZkaHuPhDaXG7JCIa4N+8jpWPtOaY+nD0QHgRVheORIgKZvMv2/kYF6e8ihxo7FIUsYb5qT6+uZRWTnJAAc0x+EJSXIlwCaUVe9Pqdn7UECmO7gAlYZAcYz20iGgymz94IUfQIQtPEp1pbPquywFCpGcnEiA+pCNFuKqSC7sjbBWawWUdOwtAxlesD/hWRmYyqUGCVVQ+HYeBZHD1DlqFHCx7PDcViFO5tNbzxpC0q+jAC1O7vK5ueYU4xpI3xa1 root@nfs.cn
spawn scp root@192.168.235.3:~/.ssh/id_rsa.pub /home/caozx26/pub
root@192.168.235.3's password: [root@samba caozx26]# ls ~/pub
ls: 无法访问/root/pub: 没有那个文件或目录
[root@samba caozx26]# ls ./pub
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# ls pub
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# ssh root@192.168.235.3
root@192.168.235.3's password:
Last login: Sat Aug 30 08:50:57 2025 from 192.168.235.10
[root@nfs ~]# ls
1.txt            initial-setup-ks.cfg  inotify-tools-3.13.tar.gz  pub
anaconda-ks.cfg  inotify-tools-3.13    nfs.sh
[root@nfs ~]# cd ~/.ssh
[root@nfs .ssh]# ls
id_rsa  id_rsa.pub  known_hosts
[root@nfs .ssh]# pwd
/root/.ssh
[root@nfs .ssh]# exit
登出
Connection to 192.168.235.3 closed.
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO0uF9+65Vnab1xc+GXvH/YqTXXfohWcTdFPtkbCzKjRez0bDAiOU9uVesqfEfQbjqcQFcwqIdR4MTSX9F+hu6dZkaHuPhDaXG7JCIa4N+8jpWPtOaY+nD0QHgRVheORIgKZvMv2/kYF6e8ihxo7FIUsYb5qT6+uZRWTnJAAc0x+EJSXIlwCaUVe9Pqdn7UECmO7gAlYZAcYz20iGgymz94IUfQIQtPEp1pbPquywFCpGcnEiA+pCNFuKqSC7sjbBWawWUdOwtAxlesD/hWRmYyqUGCVVQ+HYeBZHD1DlqFHCx7PDcViFO5tNbzxpC0q+jAC1O7vK5ueYU4xpI3xa1 root@nfs.cn
spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub
root@192.168.235.3's password: [root@samba caozx26]# ls /home/caozx26/pub/
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO0uF9+65Vnab1xc+GXvH/YqTXXfohWcTdFPtkbCzKjRez0bDAiOU9uVesqfEfQbjqcQFcwqIdR4MTSX9F+hu6dZkaHuPhDaXG7JCIa4N+8jpWPtOaY+nD0QHgRVheORIgKZvMv2/kYF6e8ihxo7FIUsYb5qT6+uZRWTnJAAc0x+EJSXIlwCaUVe9Pqdn7UECmO7gAlYZAcYz20iGgymz94IUfQIQtPEp1pbPquywFCpGcnEiA+pCNFuKqSC7sjbBWawWUdOwtAxlesD/hWRmYyqUGCVVQ+HYeBZHD1DlqFHCx7PDcViFO5tNbzxpC0q+jAC1O7vK5ueYU4xpI3xa1 root@nfs.cn
spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub/
root@192.168.235.3's password: [root@samba caozx26]# ls ./pub
[root@samba caozx26]# ls pub
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}
interact
spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./rsa.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password: spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub/
root@192.168.235.3's password:
id_rsa.pub                                     100%  393   199.5KB/s   00:00
[root@samba caozx26]# ls pub
id_rsa.pub
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh  until1.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     pub     until.sh   模板  文档  桌面
inotify.sh  ll  ntpdate.sh  rsa.sh  utilc.sh   视频  下载
[root@samba caozx26]# ip2=192.168.235.23
[root@samba caozx26]# cat ip2 | cut -d "." -f1-3
cat: ip2: 没有那个文件或目录
[root@samba caozx26]# echo ip2 | cut -d "." -f1-3
ip2
[root@samba caozx26]# cat ip2
cat: ip2: 没有那个文件或目录
[root@samba caozx26]# ls ip2
ls: 无法访问ip2: 没有那个文件或目录
[root@samba caozx26]# echo "ip2"
ip2
[root@samba caozx26]# echo $ip2
192.168.235.23
[root@samba caozx26]# echo $ip2 | cut -d "." -f1-3
192.168.235
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# echo $ip2 | cut -d "." -f1-3 | ip3
bash: ip3: 未找到命令...
[root@samba caozx26]# ip3=$(( echo $ip2 | cut -d "." -f1-3 ))
bash: echo 192.168.235.23 | cut -d "." -f1-3 : 表达式中有语法错误 (错误符号是 "192.168.235.23 | cut -d "." -f1-3 "[root@samba caozx26]# ip3=$( echo $ip2 | cut -d "." -f1-3 )
[root@samba caozx26]# echo $ip3
192.168.235
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
read -p "please input:"ip2
ip3=$( echo $ip2 | cut -d "." -f1-3 )
if [ $ip3!=192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./rsa.sh
please input:ip2^C[root@samba caozx26]# ./rsa.sh
please input:ip2192.168.235.34not in the same net
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
read -p "please input:" ip2
ip3=$( echo "$ip2" | cut -d "." -f1-3 )
if [ "$ip3"!=192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./rsa.sh
please input:192.168.235.23
192.168.235.23 not in the same net
[root@samba caozx26]# echo $ip3
192.168.235
[root@samba caozx26]# cat rsa.sh
read -p "please input:" ip2
ip3=$( echo "$ip2" | cut -d "." -f1-3 )
if [ "$ip3"!=192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
read -p "please input:" ip2
ip3=$( echo "$ip2" | cut -d "." -f1-3 )
if [ "$ip3" != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./rsa.sh
please input:192.168.235.23
./rsa.sh:行11: spawn: 未找到命令
couldn't read file "{": no such file or directory
./rsa.sh:行13: yes/no: 没有那个文件或目录
./rsa.sh:行13: exp_continue: 未找到命令
./rsa.sh:行14: password: 未找到命令
./rsa.sh:行16: 未预期的符号 `}' 附近有语法错误
./rsa.sh:行16: `}'
[root@samba caozx26]# vim ping.sh
[root@samba caozx26]# cat ping.sh
./rsa.sh
read -p "please input:" ip2
ip=$( echo "$ip2" | cut -d "." -f1-3 )
if [ $ip != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
scp /home/caozx26/pub/id_rsa.pub root@$ip2 /root/[root@samba caozx26]# vim rsa.sh
[root@samba caozx26]# cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[root@samba caozx26]# ./ping.sh
bash: ./ping.sh: 权限不够
[root@samba caozx26]# chmod +x ping.sh
[root@samba caozx26]# ./ping.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password: spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub/
root@192.168.235.3's password:
id_rsa.pub                                     100%  393   292.4KB/s   00:00
please input:192.168.235.100
cp: 无法获取"root@192.168.235.100" 的文件状态(stat): 没有那个文件或目录
[root@samba caozx26]# vim ping.sh
[root@samba caozx26]# cat ping.sh
./rsa.sh
read -p "please input:" ip2
ip=$( echo "$ip2" | cut -d "." -f1-3 )
if [ $ip != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
scp /home/caozx26/pub/id_rsa.pub root@$ip2:/root/[root@samba caozx26]# ./ping.sh
spawn ssh root@192.168.235.3 cat  ~/.ssh/id_rsa.pub
root@192.168.235.3's password: spawn scp root@192.168.235.3:/root/.ssh/id_rsa.pub /home/caozx26/pub/
root@192.168.235.3's password:
id_rsa.pub                                     100%  393   254.3KB/s   00:00
please input:192.168.235.100
id_rsa.pub                                     100%  393   246.3KB/s   00:00
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh   rsa.sh     utilc.sh  视频  下载
find.sh     l2  ntp1.sh     ping.sh  until1.sh  公共      图片  音乐
inotify.sh  ll  ntpdate.sh  pub      until.sh   模板      文档  桌面
[root@samba caozx26]#
Network error: Software caused connection abort─────────────────────────────────────────────────────────────────────────────────Session stopped- Press <Return> to exit tab- Press R to restart session- Press S to save terminal output to file┌──────────────────────────────────────────────────────────────────────┐│                 • MobaXterm Personal Edition v23.2 •                 ││               (SSH client, X server and network tools)               ││                                                                      ││ ⮞ SSH session to code@192.168.235.10                                 ││   • Direct SSH      :  ✓                                             ││   • SSH compression :  ✓                                             ││   • SSH-browser     :  ✓                                             ││   • X11-forwarding  :(remote display is forwarded through SSH)  ││                                                                      ││ ⮞ For more info, ctrl+click on help or visit our website.            │└──────────────────────────────────────────────────────────────────────┘Last login: Sat Aug 30 08:27:20 2025 from 192.168.235.1
[code@samba ~]$
    ┌──────────────────────────────────────────────────────────────────────┐│                 • MobaXterm Personal Edition v23.2 •                 ││               (SSH client, X server and network tools)               ││                                                                      ││ ⮞ SSH session to backup@192.168.235.100                              ││   • Direct SSH      :  ✓                                             ││   • SSH compression :  ✓                                             ││   • SSH-browser     :  ✓                                             ││   • X11-forwarding  :(remote display is forwarded through SSH)  ││                                                                      ││ ⮞ For more info, ctrl+click on help or visit our website.            │└──────────────────────────────────────────────────────────────────────┘Last login: Sat Aug 16 08:38:44 2025 from 192.168.235.1
[backup@backup ~]$ su - caozx26
密码:
上一次登录:五 815 20:43:36 CST 2025pts/1 上
[caozx26@backup ~]$ sudo su
[sudo] caozx26 的密码:
[root@backup caozx26]#
Network error: Software caused connection abort────────────────────────────────────────────────────────────────────────────Session stopped- Press <Return> to exit tab- Press R to restart session- Press S to save terminal output to file┌───────────────────────────────────────────────────────────────────         ───┐│                 • MobaXterm Personal Edition v23.2 •                          ││               (SSH client, X server and network tools)                        ││                                                                               ││ ⮞ SSH session to backup@192.168.235.100                                       ││   • Direct SSH      :  ✓                                                      ││   • SSH compression :  ✓                                                      ││   • SSH-browser     :  ✓                                                      ││   • X11-forwarding  :(remote display is forwarded through SSH         )  ││                                                                               ││ ⮞ For more info, ctrl+click on help or visit our website.                     │└───────────────────────────────────────────────────────────────────         ───┘Last login: Sun Aug 17 08:10:33 2025 from 192.168.235.1
[backup@backup ~]$
Network error: Software caused connection abort────────────────────────────────────────────────────────────────────────Session stopped- Press <Return> to exit tab- Press R to restart session- Press S to save terminal output to file┌───────────────────────────────────────────────────────────────────         ───┐│                 • MobaXterm Personal Edition v23.2 •                          ││               (SSH client, X server and network tools)                        ││                                                                               ││ ⮞ SSH session to backup@192.168.235.100                                       ││   • Direct SSH      :  ✓                                                      ││   • SSH compression :  ✓                                                      ││   • SSH-browser     :  ✓                                                      ││   • X11-forwarding  :(remote display is forwarded through SSH         )  ││                                                                               ││ ⮞ For more info, ctrl+click on help or visit our website.                     │└───────────────────────────────────────────────────────────────────         ───┘Last login: Wed Aug 20 21:26:31 2025 from 192.168.235.1
[backup@backup ~]$ R
Network error: Software caused connection abort────────────────────────────────────────────────────────────────────────Session stopped- Press <Return> to exit tab- Press R to restart session- Press S to save terminal output to file┌──────────────────────────────────────────────────────────────────────┐│                 • MobaXterm Personal Edition v23.2 •                 ││               (SSH client, X server and network tools)               ││                                                                      ││ ⮞ SSH session to backup@192.168.235.100                              ││   • Direct SSH      :  ✓                                             ││   • SSH compression :  ✓                                             ││   • SSH-browser     :  ✓                                             ││   • X11-forwarding  :(remote display is forwarded through SSH)  ││                                                                      ││ ⮞ For more info, ctrl+click on help or visit our website.            │└──────────────────────────────────────────────────────────────────────┘Last login: Wed Aug 20 21:35:59 2025 from 192.168.235.1
[backup@backup ~]$ ls
公共  模板  视频  图片  文档  下载  音乐  桌面
[backup@backup ~]$ ls /root
2010    aa3              file4.java  file9.java            rsync_java.sh
23.txt  anaconda-ks.cfg  file5.java  id_rsa.pub            shop
2.java  file1.java       file6.java  initial-setup-ks.cfg
aa1     file2.java       file7.java  linux.txt
aa2     file3.java       file8.java  q
[backup@backup ~]$ ll -d id_rsa.pub
ls: 无法访问id_rsa.pub: 没有那个文件或目录
[backup@backup ~]$ ll
总用量 0
drwxr-xr-x. 2 backup backup 6 621 04:34 公共
drwxr-xr-x. 2 backup backup 6 621 04:34 模板
drwxr-xr-x. 2 backup backup 6 621 04:34 视频
drwxr-xr-x. 2 backup backup 6 621 04:34 图片
drwxr-xr-x. 2 backup backup 6 621 04:34 文档
drwxr-xr-x. 2 backup backup 6 621 04:34 下载
drwxr-xr-x. 2 backup backup 6 621 04:34 音乐
drwxr-xr-x. 2 backup backup 6 621 04:34 桌面
[backup@backup ~]$ ll /root
总用量 14352
drwxr-xr-x. 2 root root      38 513 20:19 2010
-rw-r--r--. 1 root root 4194304 513 20:09 23.txt
-rw-r--r--. 1 root root 6291456 515 21:30 2.java
drwxr-xr-x. 2 root root       6 515 20:51 aa1
drwxr-xr-x. 2 root root       6 515 20:51 aa2
drwxr-xr-x. 2 root root       6 515 20:51 aa3
-rw-------. 1 root root    1827 417 05:53 anaconda-ks.cfg
-rw-r--r--. 1 root root       0 515 20:54 file1.java
-rw-r--r--. 1 root root       0 515 20:54 file2.java
-rw-r--r--. 1 root root       0 515 20:54 file3.java
-rw-r--r--. 1 root root       0 515 20:54 file4.java
-rw-r--r--. 1 root root       0 515 20:54 file5.java
-rw-r--r--. 1 root root       0 515 20:54 file6.java
-rw-r--r--. 1 root root       0 515 20:54 file7.java
-rw-r--r--. 1 root root       0 515 20:54 file8.java
-rw-r--r--. 1 root root       0 515 20:54 file9.java
-rw-r--r--. 1 root root     393 830 11:13 id_rsa.pub
-rw-r--r--. 1 root root    1875 417 06:04 initial-setup-ks.cfg
-rw-r--r--. 1 root root 4194304 513 18:57 linux.txt
drwxr-xr-x. 2 root root       6 513 20:37 q
-rwxr-xr-x. 1 root root      83 61 21:39 rsync_java.sh
drwxr-xr-x. 2 root root       6 513 20:02 shop
[backup@backup ~]$
Network error: Software caused connection abort─────────────────────────────────────────────────────────────────────────────────Session stopped- Press <Return> to exit tab- Press R to restart session- Press S to save terminal output to file
    ┌──────────────────────────────────────────────────────────────────────│                 • MobaXterm Personal Edition v23.2 •│               (SSH client, X server and network tools)││ ⮞ SSH session to code@192.168.235.10│   • Direct SSH      :  ✓│   • SSH compression :  ✓│   • SSH-browser     :  ✓│   • X11-forwarding  :(remote display is forwarded through SSH)││ ⮞ For more info, ctrl+click on help or visit our website.└──────────────────────────────────────────────────────────────────────Last login: Sat Aug 30 13:34:16 2025 from 192.168.235.1
[code@samba ~]$ ls
1                       for4.sh                    network3.txt  test:+.sh
1.sh                    httpd-2.4.37.tar.bz2       network.txt   test+.sh
2.txt                   id.sh                      nohup.out     uname.sh
3.sh                    inotify.sh                 nt.sh         url2.sh
3.txt                   inotify-tools-3.13         passwd        url3.sh
apr-1.5.2.tar.bz2       inotify-tools-3.13.tar.gz  passwd1.txt   url.sh
apr-util-1.5.4.tar.bz2  ip.txt                     passwd2       公共
axel-1.0a.tar.gz        judge.sh                   passwd3       模板
axel-2.4                mac1.txt                   ping.sh       视频
axel-2.4.tar.gz         mac.txt                    ps.sh         图片
bash_var.sh             MAC.txt                    shift.sh      文档
broadcast.txt           mysql-5.6.31.tar.gz        test?1.sh     下载
ef.sh                   netmask.txt                test-.sh      音乐
file1                   network1.txt               test:-.sh     桌面
for3.sh                 network2.txt               test:.sh
[code@samba ~]$ cat rsa.sh
cat: rsa.sh: 没有那个文件或目录
[code@samba ~]$ cd /home/caozx26/
-bash: cd: /home/caozx26/: 权限不够
[code@samba ~]$ ls
1                       for4.sh                    network3.txt  test:+.sh
1.sh                    httpd-2.4.37.tar.bz2       network.txt   test+.sh
2.txt                   id.sh                      nohup.out     uname.sh
3.sh                    inotify.sh                 nt.sh         url2.sh
3.txt                   inotify-tools-3.13         passwd        url3.sh
apr-1.5.2.tar.bz2       inotify-tools-3.13.tar.gz  passwd1.txt   url.sh
apr-util-1.5.4.tar.bz2  ip.txt                     passwd2       公共
axel-1.0a.tar.gz        judge.sh                   passwd3       模板
axel-2.4                mac1.txt                   ping.sh       视频
axel-2.4.tar.gz         mac.txt                    ps.sh         图片
bash_var.sh             MAC.txt                    shift.sh      文档
broadcast.txt           mysql-5.6.31.tar.gz        test?1.sh     下载
ef.sh                   netmask.txt                test-.sh      音乐
file1                   network1.txt               test:-.sh     桌面
for3.sh                 network2.txt               test:.sh
[code@samba ~]$ su -caozx26
密码:
su: 鉴定故障
[code@samba ~]$ su - caox26
su: user caox26 does not exist
[code@samba ~]$ su - caozx26
密码:
上一次登录:六 830 08:28:09 CST 2025pts/0 上
[caozx26@samba ~]$ ls
app         km  nntp.sh     ntp.sh   rsa.sh     utilc.sh  视频  下载
find.sh     l2  ntp1.sh     ping.sh  until1.sh  公共      图片  音乐
inotify.sh  ll  ntpdate.sh  pub      until.sh   模板      文档  桌面
[caozx26@samba ~]$ cat rsa.sh
#!/bin/expect
set ip 192.168.235.3
set pass 123456
set timeout 30
spawn ssh root@$ip "cat  ~/.ssh/id_rsa.pub"
expect {"yes/no" { send "yes\r";exp_continue }"password" { send "$pass\r" }}spawn scp root@$ip:/root/.ssh/id_rsa.pub /home/caozx26/pub/
expect {"password" { send "$pass\r" }
}
expect eof
[caozx26@samba ~]$ cat ping.sh
./rsa.sh
read -p "please input:" ip2
ip=$( echo "$ip2" | cut -d "." -f1-3 )
if [ $ip != 192.168.235 ];then
echo "$ip2 not in the same net"
exit 1
fi
scp /home/caozx26/pub/id_rsa.pub root@$ip2:/root/[caozx26@samba ~]$ netstat -an | grep -c ':80\|:443'
0
[caozx26@samba ~]$ a=$( netstat -an | grep -c ':80\|:443' )
[caozx26@samba ~]$ echo $a
0
[caozx26@samba ~]$ vim wc.sh
[caozx26@samba ~]$ cat wc.sh
#!/bin/bash
#count_http_80_stat
declare -A array1
states='netstat -an | grep -c ':80\|:443''
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array[$j]}
done
[caozx26@samba ~]$ chmod +x wc.sh
[caozx26@samba ~]$ ./wc.sh
grep:
netstat:
./wc.sh:行11: :80|:443: 语法错误: 期待操作数 (错误符号是 ":80|:443"[caozx26@samba ~]$ cat wc.sh
#!/bin/bash
#count_http_80_stat
declare -A array1
states='netstat -an | grep -c ':80\|:443''
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array[$j]}
done
[caozx26@samba ~]$ vim wc.sh
[caozx26@samba ~]$ cat wc.sh
#!/bin/bash
#count_http_80_stat
declare -A array1
states="netstat -an | grep -c ':80\|:443'"
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array[$j]}
done
[caozx26@samba ~]$ ./wc.sh
grep:
netstat:
-an:
./wc.sh:行11: :80\|:443: 语法错误: 期待操作数 (错误符号是 ":80\|:443"[caozx26@samba ~]$ vim wc.sh
[caozx26@samba ~]$ cat wc.sh
#!/bin/bash
#count_http_80_stat
declare -A array1
states=$(netstat -an | grep -c ':80\|:443')
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array[$j]}
done
[caozx26@samba ~]$ ./wc.sh
0:
[caozx26@samba ~]$ vim wc1.sh
[caozx26@samba ~]$ cat wc1.sh
#!/bin/bash
#count_http_80_state
declare -A array1
states=`ss -ant|grep 80|cut d' ' -f1`
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array1[$j]}
done
[caozx26@samba ~]$ chmod +x wc1.sh
[caozx26@samba ~]$ ./wc1.sh
cut: d : 没有那个文件或目录
[caozx26@samba ~]$ vim wc1.sh[已修改但尚未保存]
/bin/bash: q: 未找到命令Shell 已返回127请按 ENTER 或其它命令继续
[caozx26@samba ~]$ ./wc1.sh
LISTEN:1
[caozx26@samba ~]$ cat wc1.sh
#!/bin/bash
#count_http_80_state
declare -A array1
states=`ss -ant|grep 80|cut -d' ' -f1`
for i in $states
dolet array1[$i]++
done
for j in ${!array1[@]}
doecho $j:${array1[$j]}
done
[caozx26@samba ~]$ ./wc1.sh
LISTEN:1
[caozx26@samba ~]$ states=`ss -ant|grep 80|cut -d' ' -f1`
[caozx26@samba ~]$ declare -A array1
[caozx26@samba ~]$ for i in $states
> do
> let array1[$i]++
> done
[caozx26@samba ~]$ echo array1
array1
[caozx26@samba ~]$ echo array1[$i]
array1[LISTEN]
[caozx26@samba ~]$ echo $states
LISTEN
[caozx26@samba ~]$
[caozx26@samba ~]$ echo ${array1[@]}
1
[caozx26@samba ~]$ echo ${array1[$i]}
1
[caozx26@samba ~]$ echo ${!array1[@]}
LISTEN
[caozx26@samba ~]$ echo ${array1[listen]}[caozx26@samba ~]$ echo ${array1[LISTEN]}
1
[caozx26@samba ~]$ echo ${!array1[@]}
LISTEN
[caozx26@samba ~]$ for j in ${!array1[@]}
> do
> echo $j:${array1[$j]}
> done
LISTEN:1
[caozx26@samba ~]$ ./wc1.sh
LISTEN:1
[caozx26@samba ~]$  tail -5 /etc/passwd
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ tail -10 /etc/passwd
df1:x:1991:1991::/home/df1:/bin/bash
df2:x:1992:1992::/home/df2:/bin/bash
df3:x:1993:1993::/home/df3:/bin/bash
df4:x:1994:1994::/home/df4:/bin/bash
df5:x:1995:1995::/home/df5:/bin/bash
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ tail -12 /etc/passwd
k10:x:1110:1110::/home/k10:/bin/bash
l10:x:10026:10040::/rhome/l10:/bin/bash
df1:x:1991:1991::/home/df1:/bin/bash
df2:x:1992:1992::/home/df2:/bin/bash
df3:x:1993:1993::/home/df3:/bin/bash
df4:x:1994:1994::/home/df4:/bin/bash
df5:x:1995:1995::/home/df5:/bin/bash
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ tail -14 /etc/passwd
k9:x:119:10038::/home/k9:/bin/bash
l9:x:10025:10039::/rhome/l9:/bin/bash
k10:x:1110:1110::/home/k10:/bin/bash
l10:x:10026:10040::/rhome/l10:/bin/bash
df1:x:1991:1991::/home/df1:/bin/bash
df2:x:1992:1992::/home/df2:/bin/bash
df3:x:1993:1993::/home/df3:/bin/bash
df4:x:1994:1994::/home/df4:/bin/bash
df5:x:1995:1995::/home/df5:/bin/bash
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ ls
app         km  nntp.sh     ntp.sh   rsa.sh     utilc.sh  公共  图片  音乐
find.sh     l2  ntp1.sh     ping.sh  until1.sh  wc1.sh    模板  文档  桌面
inotify.sh  ll  ntpdate.sh  pub      until.sh   wc.sh     视频  下载
[caozx26@samba ~]$ cat find.sh
#!/bin/bash
find /tmp/run
if [ $? -ne 0 ];
then
mkdir -p /tmp/run
else
rm -rf /tmp/run/*
fi[caozx26@samba ~]$ uid=$( cat /etc/passwd |cut -d ":" -f3 )
[caozx26@samba ~]$ echo $uid
0 1 2 3 4 5 6 7 8 11 12 14 99 192 81 999 998 997 32 996 995 994 173 993 172 171 75 992 991 107 59 990 113 989 38 42 29 65534 988 74 70 89 72 1000 1001 1002 48 1003 1004 13 987 1005 10001 10002 10003 10004 10005 10006 10007 10008 10009 100010 100 101 102 103 104 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 111 112 114 115 116 10022 117 10023 118 10024 119 10025 1110 10026 1991 1992 1993 1994 1995 10027 10028 10029 10030 10031
[caozx26@samba ~]$ if [ $uid -eq 0 ];then
> sort -n^C
[caozx26@samba ~]$ grep -o "$uid=0" /etc/passwd
0
0
1
1
2
2
3
4
4
7
5
0
6
0
7
0
8
12
11
0
12
100
14
5
0
99
99
192
192
81
81
999
998
998
995
997
994
32
32
996
993
995
992
994
7
6
173
173
993
990
172
172
171
171
75
75
992
987
991
8
6
107
107
59
59
990
8
4
113
113
989
8
3
38
38
42
42
29
29
65534
65534
988
8
2
74
74
70
70
89
89
72
72
2
6
1000
1000
2
6
2
6
1001
1001
1002
1002
48
48
0
1
1003
1003
0
1
0
2
1004
1005
0
2
0
3
13
48
0
3
987
81
5
1005
100
6
5
1
10001
10001
1
2
10002
10002
2
3
10003
10003
3
4
10004
10004
4
5
10005
10005
5
6
10006
10006
6
7
10007
10007
7
8
10008
10008
8
10009
10009
1
0
100010
10010
1
0
0
100
10011
0
1
101
10012
1
2
102
10013
2
3
103
10014
3
4
104
10015
4
6
10010
10016
6
7
10011
10017
7
8
10012
10018
8
10013
10019
1
0
10014
10020
1
0
11
10015
10021
11
6
10016
10022
6
7
10017
10023
7
8
10018
10024
8
10019
10025
1
0
10020
10026
1
0
11
10021
10027
11
1
111
10028
1
2
112
10029
2
4
114
10030
4
5
115
1003
1
5
6
116
1003
2
6
6
10022
1003
3
6
7
117
1003
4
7
7
10023
1003
5
7
8
118
1003
6
8
8
10024
1003
7
8
119
1003
8
10025
1003
1
0
1110
1110
1
0
1
0
10026
1004
0
1
0
1
1991
1991
1
2
1992
1992
2
3
1993
1993
3
4
1994
1994
4
5
1995
1995
5
6
10027
1004
1
1
996
7
10028
1004
2
1
997
8
10029
1004
3
1
998
10030
1004
4
1
999
1
0
1003
1
1004
5
1991
0
[caozx26@samba ~]$ grep "$uid='0'" /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
caozx26:x:1000:1000:caozx26:/home/caozx26:/bin/bash
code:x:1001:1001::/home/code:/bin/bash
rsync:x:1002:1002::/home/rsync:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
user01:x:1003:1003::/home/user01:/bin/bash
u02:x:1004:1005::/home/u02:/bin/bash
u03:x:13:48::/home/u03:/bin/bash
mysql:x:987:981::/home/mysql:/sbin/nologin
stu5:x:1005:1006::/home/stu5:/bin/bash
stuu1:x:10001:10001::/home/stuu1:/bin/bash
stuu2:x:10002:10002::/home/stuu2:/bin/bash
stuu3:x:10003:10003::/home/stuu3:/bin/bash
stuu4:x:10004:10004::/home/stuu4:/bin/bash
stuu5:x:10005:10005::/home/stuu5:/bin/bash
stuu6:x:10006:10006::/home/stuu6:/bin/bash
stuu7:x:10007:10007::/home/stuu7:/bin/bash
stuu8:x:10008:10008::/home/stuu8:/bin/bash
stuu9:x:10009:10009::/home/stuu9:/bin/bash
stuu10:x:100010:10010::/home/stuu10:/bin/bash
stu0:x:100:10011::/home/stu0:/bin/bash
stu1:x:101:10012::/home/stu1:/bin/bash
stu2:x:102:10013::/home/stu2:/bin/bash
stu3:x:103:10014::/home/stu3:/bin/bash
stu4:x:104:10015::/home/stu4:/bin/bash
stt6:x:10010:10016::/rhome/stt6:/bin/bash
stt7:x:10011:10017::/rhome/stt7:/bin/bash
stt8:x:10012:10018::/rhome/stt8:/bin/bash
stt9:x:10013:10019::/rhome/stt9:/bin/bash
stt10:x:10014:10020::/rhome/stt10:/bin/bash
stt11:x:10015:10021::/rhome/stt11:/bin/bash
ss6:x:10016:10022::/rhome/ss6:/bin/bash
ss7:x:10017:10023::/rhome/ss7:/bin/bash
ss8:x:10018:10024::/rhome/ss8:/bin/bash
ss9:x:10019:10025::/rhome/ss9:/bin/bash
ss10:x:10020:10026::/rhome/ss10:/bin/bash
ss11:x:10021:10027::/rhome/ss11:/bin/bash
k1:x:111:10028::/home/k1:/bin/bash
k2:x:112:10029::/home/k2:/bin/bash
k4:x:114:10030::/home/k4:/bin/bash
k5:x:115:10031::/home/k5:/bin/bash
k6:x:116:10032::/home/k6:/bin/bash
l6:x:10022:10033::/rhome/l6:/bin/bash
k7:x:117:10034::/home/k7:/bin/bash
l7:x:10023:10035::/rhome/l7:/bin/bash
k8:x:118:10036::/home/k8:/bin/bash
l8:x:10024:10037::/rhome/l8:/bin/bash
k9:x:119:10038::/home/k9:/bin/bash
l9:x:10025:10039::/rhome/l9:/bin/bash
k10:x:1110:1110::/home/k10:/bin/bash
l10:x:10026:10040::/rhome/l10:/bin/bash
df1:x:1991:1991::/home/df1:/bin/bash
df2:x:1992:1992::/home/df2:/bin/bash
df3:x:1993:1993::/home/df3:/bin/bash
df4:x:1994:1994::/home/df4:/bin/bash
df5:x:1995:1995::/home/df5:/bin/bash
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ echo $uid
0 1 2 3 4 5 6 7 8 11 12 14 99 192 81 999 998 997 32 996 995 994 173 993 172 171 75 992 991 107 59 990 113 989 38 42 29 65534 988 74 70 89 72 1000 1001 1002 48 1003 1004 13 987 1005 10001 10002 10003 10004 10005 10006 10007 10008 10009 100010 100 101 102 103 104 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 111 112 114 115 116 10022 117 10023 118 10024 119 10025 1110 10026 1991 1992 1993 1994 1995 10027 10028 10029 10030 10031
[caozx26@samba ~]$ grep $uid="0" /etc/passwd
grep: 1: 没有那个文件或目录
grep: 2: 没有那个文件或目录
grep: 3: 没有那个文件或目录
grep: 4: 没有那个文件或目录
grep: 5: 没有那个文件或目录
grep: 6: 没有那个文件或目录
grep: 7: 没有那个文件或目录
grep: 8: 没有那个文件或目录
grep: 11: 没有那个文件或目录
grep: 12: 没有那个文件或目录
grep: 14: 没有那个文件或目录
grep: 99: 没有那个文件或目录
grep: 192: 没有那个文件或目录
grep: 81: 没有那个文件或目录
grep: 999: 没有那个文件或目录
grep: 998: 没有那个文件或目录
grep: 997: 没有那个文件或目录
grep: 32: 没有那个文件或目录
grep: 996: 没有那个文件或目录
grep: 995: 没有那个文件或目录
grep: 994: 没有那个文件或目录
grep: 173: 没有那个文件或目录
grep: 993: 没有那个文件或目录
grep: 172: 没有那个文件或目录
grep: 171: 没有那个文件或目录
grep: 75: 没有那个文件或目录
grep: 992: 没有那个文件或目录
grep: 991: 没有那个文件或目录
grep: 107: 没有那个文件或目录
grep: 59: 没有那个文件或目录
grep: 990: 没有那个文件或目录
grep: 113: 没有那个文件或目录
grep: 989: 没有那个文件或目录
grep: 38: 没有那个文件或目录
grep: 42: 没有那个文件或目录
grep: 29: 没有那个文件或目录
grep: 65534: 没有那个文件或目录
grep: 988: 没有那个文件或目录
grep: 74: 没有那个文件或目录
grep: 70: 没有那个文件或目录
grep: 89: 没有那个文件或目录
grep: 72: 没有那个文件或目录
grep: 1000: 没有那个文件或目录
grep: 1001: 没有那个文件或目录
grep: 1002: 没有那个文件或目录
grep: 48: 没有那个文件或目录
grep: 1003: 没有那个文件或目录
grep: 1004: 没有那个文件或目录
grep: 13: 没有那个文件或目录
grep: 987: 没有那个文件或目录
grep: 1005: 没有那个文件或目录
grep: 10001: 没有那个文件或目录
grep: 10002: 没有那个文件或目录
grep: 10003: 没有那个文件或目录
grep: 10004: 没有那个文件或目录
grep: 10005: 没有那个文件或目录
grep: 10006: 没有那个文件或目录
grep: 10007: 没有那个文件或目录
grep: 10008: 没有那个文件或目录
grep: 10009: 没有那个文件或目录
grep: 100010: 没有那个文件或目录
grep: 100: 没有那个文件或目录
grep: 101: 没有那个文件或目录
grep: 102: 没有那个文件或目录
grep: 103: 没有那个文件或目录
grep: 104: 没有那个文件或目录
grep: 10010: 没有那个文件或目录
grep: 10011: 没有那个文件或目录
grep: 10012: 没有那个文件或目录
grep: 10013: 没有那个文件或目录
grep: 10014: 没有那个文件或目录
grep: 10015: 没有那个文件或目录
grep: 10016: 没有那个文件或目录
grep: 10017: 没有那个文件或目录
grep: 10018: 没有那个文件或目录
grep: 10019: 没有那个文件或目录
grep: 10020: 没有那个文件或目录
grep: 10021: 没有那个文件或目录
grep: 111: 没有那个文件或目录
grep: 112: 没有那个文件或目录
grep: 114: 没有那个文件或目录
grep: 115: 没有那个文件或目录
grep: 116: 没有那个文件或目录
grep: 10022: 没有那个文件或目录
grep: 117: 没有那个文件或目录
grep: 10023: 没有那个文件或目录
grep: 118: 没有那个文件或目录
grep: 10024: 没有那个文件或目录
grep: 119: 没有那个文件或目录
grep: 10025: 没有那个文件或目录
grep: 1110: 没有那个文件或目录
grep: 10026: 没有那个文件或目录
grep: 1991: 没有那个文件或目录
grep: 1992: 没有那个文件或目录
grep: 1993: 没有那个文件或目录
grep: 1994: 没有那个文件或目录
grep: 1995: 没有那个文件或目录
grep: 10027: 没有那个文件或目录
grep: 10028: 没有那个文件或目录
grep: 10029: 没有那个文件或目录
grep: 10030: 没有那个文件或目录
grep: 10031=0: 没有那个文件或目录
/etc/passwd:root:x:0:0:root:/root:/bin/bash
/etc/passwd:sync:x:5:0:sync:/sbin:/bin/sync
/etc/passwd:shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
/etc/passwd:halt:x:7:0:halt:/sbin:/sbin/halt
/etc/passwd:operator:x:11:0:operator:/root:/sbin/nologin
/etc/passwd:games:x:12:100:games:/usr/games:/sbin/nologin
/etc/passwd:ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
/etc/passwd:setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
/etc/passwd:qemu:x:107:107:qemu user:/:/sbin/nologin
/etc/passwd:sssd:x:990:984:User for sssd:/:/sbin/nologin
/etc/passwd:avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
/etc/passwd:caozx26:x:1000:1000:caozx26:/home/caozx26:/bin/bash
/etc/passwd:code:x:1001:1001::/home/code:/bin/bash
/etc/passwd:rsync:x:1002:1002::/home/rsync:/sbin/nologin
/etc/passwd:user01:x:1003:1003::/home/user01:/bin/bash
/etc/passwd:u02:x:1004:1005::/home/u02:/bin/bash
/etc/passwd:u03:x:13:48::/home/u03:/bin/bash
/etc/passwd:stu5:x:1005:1006::/home/stu5:/bin/bash
/etc/passwd:stuu1:x:10001:10001::/home/stuu1:/bin/bash
/etc/passwd:stuu2:x:10002:10002::/home/stuu2:/bin/bash
/etc/passwd:stuu3:x:10003:10003::/home/stuu3:/bin/bash
/etc/passwd:stuu4:x:10004:10004::/home/stuu4:/bin/bash
/etc/passwd:stuu5:x:10005:10005::/home/stuu5:/bin/bash
/etc/passwd:stuu6:x:10006:10006::/home/stuu6:/bin/bash
/etc/passwd:stuu7:x:10007:10007::/home/stuu7:/bin/bash
/etc/passwd:stuu8:x:10008:10008::/home/stuu8:/bin/bash
/etc/passwd:stuu9:x:10009:10009::/home/stuu9:/bin/bash
/etc/passwd:stuu10:x:100010:10010::/home/stuu10:/bin/bash
/etc/passwd:stu0:x:100:10011::/home/stu0:/bin/bash
/etc/passwd:stu1:x:101:10012::/home/stu1:/bin/bash
/etc/passwd:stu2:x:102:10013::/home/stu2:/bin/bash
/etc/passwd:stu3:x:103:10014::/home/stu3:/bin/bash
/etc/passwd:stu4:x:104:10015::/home/stu4:/bin/bash
/etc/passwd:stt6:x:10010:10016::/rhome/stt6:/bin/bash
/etc/passwd:stt7:x:10011:10017::/rhome/stt7:/bin/bash
/etc/passwd:stt8:x:10012:10018::/rhome/stt8:/bin/bash
/etc/passwd:stt9:x:10013:10019::/rhome/stt9:/bin/bash
/etc/passwd:stt10:x:10014:10020::/rhome/stt10:/bin/bash
/etc/passwd:stt11:x:10015:10021::/rhome/stt11:/bin/bash
/etc/passwd:ss6:x:10016:10022::/rhome/ss6:/bin/bash
/etc/passwd:ss7:x:10017:10023::/rhome/ss7:/bin/bash
/etc/passwd:ss8:x:10018:10024::/rhome/ss8:/bin/bash
/etc/passwd:ss9:x:10019:10025::/rhome/ss9:/bin/bash
/etc/passwd:ss10:x:10020:10026::/rhome/ss10:/bin/bash
/etc/passwd:ss11:x:10021:10027::/rhome/ss11:/bin/bash
/etc/passwd:k1:x:111:10028::/home/k1:/bin/bash
/etc/passwd:k2:x:112:10029::/home/k2:/bin/bash
/etc/passwd:k4:x:114:10030::/home/k4:/bin/bash
/etc/passwd:k5:x:115:10031::/home/k5:/bin/bash
/etc/passwd:k6:x:116:10032::/home/k6:/bin/bash
/etc/passwd:l6:x:10022:10033::/rhome/l6:/bin/bash
/etc/passwd:k7:x:117:10034::/home/k7:/bin/bash
/etc/passwd:l7:x:10023:10035::/rhome/l7:/bin/bash
/etc/passwd:k8:x:118:10036::/home/k8:/bin/bash
/etc/passwd:l8:x:10024:10037::/rhome/l8:/bin/bash
/etc/passwd:k9:x:119:10038::/home/k9:/bin/bash
/etc/passwd:l9:x:10025:10039::/rhome/l9:/bin/bash
/etc/passwd:k10:x:1110:1110::/home/k10:/bin/bash
/etc/passwd:l10:x:10026:10040::/rhome/l10:/bin/bash
/etc/passwd:dfs6:x:10027:10041::/rhome/1996:/bin/bash
/etc/passwd:dfs7:x:10028:10042::/rhome/1997:/bin/bash
/etc/passwd:dfs8:x:10029:10043::/rhome/1998:/bin/bash
/etc/passwd:dfs9:x:10030:10044::/rhome/1999:/bin/bash
/etc/passwd:dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ grep ':0' /etc/passwd
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
[caozx26@samba ~]$ grep ':0:' /etc/passwd
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
[caozx26@samba ~]$ grep ':0:0:' /etc/passwd
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
li=$( cut -d ":" -f3 < "rf.txt" )
while IFS= read -r line;do
if $li="0"
echo "$line"
fi
done < "rf.txt"[caozx26@samba ~]$ chmod +x us.sh
[caozx26@samba ~]$ ./us.sh
./us.sh:行6: 未预期的符号 `fi' 附近有语法错误
./us.sh:行6: `fi'
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
li=$( cut -d ":" -f3 < "rf.txt" )
while IFS= read -r line;do
if [ $li -eq 0 ];then
echo "$line"
fi
done < "rf.txt"[caozx26@samba ~]$ ./us.sh
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
./us.sh: 第 4 行:[: 参数太多
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"
fi
done < "rf.txt"[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"
fi
done < "rf.txt"[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line">>root.txt
fi
done < "rf.txt"[caozx26@samba ~]$ ./us.sh
[caozx26@samba ~]$ cat root.txt
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shgrep ':0:' /etc/passwd >> rf.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
fi
done < "rf.txt"[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ grep ':0:' /etc/passwd
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
[caozx26@samba ~]$ cat rf.txt
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
[caozx26@samba ~]$ grep ':0:'> r2.txt
^C
[caozx26@samba ~]$ grep ':0:' /etc/passwd > r2.txt
[caozx26@samba ~]$ cat r2.txt
root:x:0:0:root:/root:/bin/bash
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shgrep  /etc/passwd > user.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
else
if [ $uid -gt 0 ]&&[ $uid -lt 1000 ];then
echo "$line">systemctlu.txt
fi
fi
if [ $uid -ge 1000 ];then
echo "line">normaluser.txt
fi
done < "user.txt"[caozx26@samba ~]$ ./us.sh
c^C[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shcat  /etc/passwd > user.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
else
if [ $uid -gt 0 ]&&[ $uid -lt 1000 ];then
echo "$line">systemctlu.txt
fi
fi
if [ $uid -ge 1000 ];then
echo "line">normaluser.txt
fi
done < "user.txt"[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ cat systemctlu.txt
k9:x:119:10038::/home/k9:/bin/bash
[caozx26@samba ~]$ cat normaluser.txt
line
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shcat  /etc/passwd > user.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
else
if [ $uid -gt 0 ]&&[ $uid -lt 1000 ];then
echo "$line">systemctlu.txt
fi
fi
if [ $uid -ge 1000 ];then
echo "$line">normaluser.txt
fi
done < "user.txt"[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ cat normaluser.txt
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ vim us.sh
[caozx26@samba ~]$ cat us.shcat  /etc/passwd > user.txt
while IFS= read -r line;do
uid=$( echo "$line" | cut -d ":" -f3 )
if [ $uid -eq 0 ];then
echo "$line"|tee root.txt
else
if [ $uid -gt 0 ]&&[ $uid -lt 1000 ];then
echo "$line">>systemctlu.txt
fi
fi
if [ $uid -ge 1000 ];then
echo "$line">>normaluser.txt
fi
done < "user.txt"[caozx26@samba ~]$ ./user.txt
-bash: ./user.txt: 权限不够
[caozx26@samba ~]$ ./user.sh
-bash: ./user.sh: 没有那个文件或目录
[caozx26@samba ~]$ ./us.sh
root:x:0:0:root:/root:/bin/bash
[caozx26@samba ~]$ cat normaluser.txt
dfs10:x:10031:10045::/rhome/19910:/bin/bash
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
caozx26:x:1000:1000:caozx26:/home/caozx26:/bin/bash
code:x:1001:1001::/home/code:/bin/bash
rsync:x:1002:1002::/home/rsync:/sbin/nologin
user01:x:1003:1003::/home/user01:/bin/bash
u02:x:1004:1005::/home/u02:/bin/bash
stu5:x:1005:1006::/home/stu5:/bin/bash
stuu1:x:10001:10001::/home/stuu1:/bin/bash
stuu2:x:10002:10002::/home/stuu2:/bin/bash
stuu3:x:10003:10003::/home/stuu3:/bin/bash
stuu4:x:10004:10004::/home/stuu4:/bin/bash
stuu5:x:10005:10005::/home/stuu5:/bin/bash
stuu6:x:10006:10006::/home/stuu6:/bin/bash
stuu7:x:10007:10007::/home/stuu7:/bin/bash
stuu8:x:10008:10008::/home/stuu8:/bin/bash
stuu9:x:10009:10009::/home/stuu9:/bin/bash
stuu10:x:100010:10010::/home/stuu10:/bin/bash
stt6:x:10010:10016::/rhome/stt6:/bin/bash
stt7:x:10011:10017::/rhome/stt7:/bin/bash
stt8:x:10012:10018::/rhome/stt8:/bin/bash
stt9:x:10013:10019::/rhome/stt9:/bin/bash
stt10:x:10014:10020::/rhome/stt10:/bin/bash
stt11:x:10015:10021::/rhome/stt11:/bin/bash
ss6:x:10016:10022::/rhome/ss6:/bin/bash
ss7:x:10017:10023::/rhome/ss7:/bin/bash
ss8:x:10018:10024::/rhome/ss8:/bin/bash
ss9:x:10019:10025::/rhome/ss9:/bin/bash
ss10:x:10020:10026::/rhome/ss10:/bin/bash
ss11:x:10021:10027::/rhome/ss11:/bin/bash
l6:x:10022:10033::/rhome/l6:/bin/bash
l7:x:10023:10035::/rhome/l7:/bin/bash
l8:x:10024:10037::/rhome/l8:/bin/bash
l9:x:10025:10039::/rhome/l9:/bin/bash
k10:x:1110:1110::/home/k10:/bin/bash
l10:x:10026:10040::/rhome/l10:/bin/bash
df1:x:1991:1991::/home/df1:/bin/bash
df2:x:1992:1992::/home/df2:/bin/bash
df3:x:1993:1993::/home/df3:/bin/bash
df4:x:1994:1994::/home/df4:/bin/bash
df5:x:1995:1995::/home/df5:/bin/bash
dfs6:x:10027:10041::/rhome/1996:/bin/bash
dfs7:x:10028:10042::/rhome/1997:/bin/bash
dfs8:x:10029:10043::/rhome/1998:/bin/bash
dfs9:x:10030:10044::/rhome/1999:/bin/bash
dfs10:x:10031:10045::/rhome/19910:/bin/bash
[caozx26@samba ~]$ cat systemctlu.txt
k9:x:119:10038::/home/k9:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:998:User for polkitd:/:/sbin/nologin
libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin
saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
chrony:x:992:987::/var/lib/chrony:/sbin/nologin
unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
sssd:x:990:984:User for sssd:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
u03:x:13:48::/home/u03:/bin/bash
mysql:x:987:981::/home/mysql:/sbin/nologin
stu0:x:100:10011::/home/stu0:/bin/bash
stu1:x:101:10012::/home/stu1:/bin/bash
stu2:x:102:10013::/home/stu2:/bin/bash
stu3:x:103:10014::/home/stu3:/bin/bash
stu4:x:104:10015::/home/stu4:/bin/bash
k1:x:111:10028::/home/k1:/bin/bash
k2:x:112:10029::/home/k2:/bin/bash
k4:x:114:10030::/home/k4:/bin/bash
k5:x:115:10031::/home/k5:/bin/bash
k6:x:116:10032::/home/k6:/bin/bash
k7:x:117:10034::/home/k7:/bin/bash
k8:x:118:10036::/home/k8:/bin/bash
k9:x:119:10038::/home/k9:/bin/bash
[caozx26@samba ~]$ date
2025年 08月 30日 星期六 20:36:28 CST
[caozx26@samba ~]$ ntpdate
30 Aug 20:43:45 ntpdate[77892]: no servers can be used, exiting
[caozx26@samba ~]$ man 5 ntpdate
在第 5 节中没有关于 ntpdate 的手册页条目。
[caozx26@samba ~]$ man 5 ntpdate
在第 5 节中没有关于 ntpdate 的手册页条目。
[caozx26@samba ~]$ vim lsdate.sh
[caozx26@samba ~]$ cat lsdate.sh
a=$(ntpdate)
[caozx26@samba ~]$ chmod +x lsdate.sh
[caozx26@samba ~]$ ./lsdate.sh
30 Aug 20:48:43 ntpdate[79707]: no servers can be used, exiting
[caozx26@samba ~]$ vim lsdate.sh
[caozx26@samba ~]$ cat lsdate.sh
a=$(date)
[caozx26@samba ~]$ ./lsdate.sh
[caozx26@samba ~]$ vim lsdate.sh
[caozx26@samba ~]$ cat lsdate.sh
a=$(date)
echo $a
[caozx26@samba ~]$ ./lsdate.sh
2025年 08月 30日 星期六 20:54:45 CST
[caozx26@samba ~]$ year=$( date | cut -d " " -f1 )
[caozx26@samba ~]$ echo $year
2025年
[caozx26@samba ~]$ month=$( date | cut -d " " -f2 )
[caozx26@samba ~]$ echo $month
08月
[caozx26@samba ~]$ day=$( date | cut -d " " -f3 )
[caozx26@samba ~]$ echo $day
30日
[caozx26@samba ~]$ time=$( date | cut -d " " -f5 )
[caozx26@samba ~]$ echo $time
21:20:15
[caozx26@samba ~]$ second=$( time |)
-bash: command substitution:行131: 未预期的符号 `|' 附近有语法错误
-bash: command substitution:行131: ` time |)'
[caozx26@samba ~]$ second=$( time | cut -d ":" -f3 )
-bash: command substitution:行132: 未预期的符号 `|' 附近有语法错误
-bash: command substitution:行132: ` time | cut -d ":" -f3 )'
[caozx26@samba ~]$ second=$( echo $time | cut -d ":" -f3 )
[caozx26@samba ~]$ echo $second
15
[caozx26@samba ~]$ date
2025年 08月 30日 星期六 21:25:57 CST
[caozx26@samba ~]$ echo $day
30[caozx26@samba ~]$ echo $date[caozx26@samba ~]$ echo $time
21:20:15
[caozx26@samba ~]$ vim upt.sh
[caozx26@samba ~]$ cat upt.sh
read -p "please input year:" y
read -p "please input month:" m
read -p "please input day:" d
year=$( date | cut -d " " -f1 )
month=$( date | cut -d " " -f2 )
day=$( date | cut -d " " -f3 )
ly=$(( $y - "$year" ))
if [ $ly -eq 1 ];else
ly=0
fi
lm=$(( "$m"-"$month" ))
if [ $lm -lt 0 ];then
lm=$(("$m"+12-"month"))
fi
ld=$(("$d"-"$day" ))
echo "距离$y$m$d还剩$ly year $lm month $ld day"
[caozx26@samba ~]$ chmod +x upt.sh
[caozx26@samba ~]$ ./upt.sh
please input year:2026
please input month:2
please input day:3
./upt.sh:行7: 2026 - "2025年" : 语法错误: 期待操作数 (错误符号是 ""2025" ")
./upt.sh:行8: 未预期的符号 `else' 附近有语法错误
./upt.sh:行8: `if [ $ly -eq 1 ];else'
[caozx26@samba ~]$
http://www.xdnf.cn/news/1396423.html

相关文章:

  • 构建AI智能体:十八、解密LangChain中的RAG架构:让AI模型突破局限学会“翻书”答题
  • Python自定义函数形式参中的*args、**kwargs、*和/
  • STM32G474 IAP 双bank升级的坑
  • WebStorm无法识别@下的文件,但是可以正常使用
  • 【后端数据库】MySQL 索引生效/失效规则 + 核心原理
  • 腾讯云OpenCloudOS 9系统部署OpenTenBase数据库详细教程
  • 【云原生】Docker 搭建Kafka服务两种方式实战操作详解
  • php连接rabbitmq例子
  • 【序列晋升】21 Spring Cloud Gateway 云原生网关演进之路
  • 卷积神经网络项目:基于CNN实现心律失常(ECG)的小颗粒度分类系统
  • HAProxy 负载均衡全解析:从基础部署、负载策略到会话保持及性能优化指南
  • docker命令(二)
  • 现状摸底:如何快速诊断企业的“数字化健康度”?
  • PCIe 6.0 TLP深度解析:从结构设计到错误处理的全链路机制
  • 算法题(194):字典树
  • 从0到1玩转 Google SEO
  • Suno-API - OpenI
  • “FAQ + AI”智能助手全栈实现方案
  • Python从入门到高手9.4节-基于字典树的敏感词识别算法
  • 8月29日星期五今日早报简报微语报早读
  • 轮廓周长,面积,外接圆,外接矩形近似轮廓和模板匹配和argparse模块实现代码参数的动态配置
  • 【C++】掌握类模板:多参数实战技巧
  • 基于Net海洋生态环境保护系统的设计与实现(代码+数据库+LW)
  • MYSQL速通(2/5)
  • 小杰机器视觉(six)——模板匹配
  • UCIE Specification详解(十)
  • TypeScript: Symbol.iterator属性
  • WINTRUST!_GetMessage函数分析之CRYPT32!CryptSIPGetSignedDataMsg函数的作用是得到nt5inf.cat的信息
  • AI的“科学革命”:Karpathy吹响号角,从“经院哲学”走向“实验科学”
  • 基于STM32单片机的智能温室控制声光报警系统设计