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

Linux817 shell:until,nfs,random

问题

[root@samba caozx26]# vim until1.sh
'[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ]
do
let i++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stt$i
fi
done
[root@samba caozx26]# ./until1.sh
useradd:用户“stu5”已存在
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@samba caozx26]#

在这里插入图片描述

[root@samba rhome]# cat ss.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 122$i 122$i
let i++
if [ $i -ge 6 ];then
mkdir -p /rhome/ss$i
useradd -d /rhome/ss$i ss$i
fi
done[root@samba rhome]# ./ss.sh
useradd:无效的用户名“1221”
useradd:无效的用户名“1222”
useradd:无效的用户名“1223”
useradd:无效的用户名“1224”
useradd:无效的用户名“1225”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1226”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1227”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1228”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1229”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“12210”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。[root@samba rhome]# tail -10 /etc/passwd
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

为什么会创建用户ss11
在这里插入图片描述

[root@samba /]# ls -l ll
lrwxrwxrwx 1 root root 4 816 11:34 ll -> dir2
[root@samba /]# read -p "w" link
wll
[root@samba /]# if [ -e "readlink -f $link " ];then
> echo "ok"
> else
> echo “no”
> fi
“no”

在这里插入图片描述

[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ -e $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi
[root@samba /]# ./judgedfl.sh
input link:ll
ll is a link
ll is useful
[root@samba /]# ./judgedfl.sh
input link:/rhome
/rhome is a link
/rhome is useful
[root@samba /]# ls
a3                      etc                   run
aa3                     home                  s2.sh
aa4                     httpd-2.4.37          samba
aa5                     httpd-2.4.37.tar.bz2  sbin
aa6                     ifdfl.sh              shell01
app                     ipping.sh             shop
apr-1.5.2               judgedfl.sh           srv
apr-1.5.2.tar.bz2       lib                   synatx.sh
apr-util-1.5.4.tar.bz2  lib64                 sys
bin                     lk                    tmp
boot                    ll                    u01
cmake.sh                media                 u02
dev                     mnt                   u1
dir1                    mysql-5.6.31          u2
dir11                   mysql-5.6.31.tar.gz   u3
dir12                   opt                   usr
dir13                   proc                  ut2
dir2                    rhome                 var
dir3                    root
[root@samba /]# ./judgedfl.sh
input link:mnt
mnt is a link
mnt is useful
[root@samba /]#

在这里插入图片描述

[root@samba /]# ls
a3                      etc                   run
aa3                     home                  s2.sh
aa4                     httpd-2.4.37          samba
aa5                     httpd-2.4.37.tar.bz2  sbin
aa6                     ifdfl.sh              shell01
app                     ipping.sh             shop
apr-1.5.2               judgedfl.sh           srv
apr-1.5.2.tar.bz2       lib                   synatx.sh
apr-util-1.5.4.tar.bz2  lib64                 sys
bin                     lk                    tmp
boot                    ll                    u01
cmake.sh                media                 u02
dev                     mnt                   u1
dir1                    mysql-5.6.31          u2
dir11                   mysql-5.6.31.tar.gz   u3
dir12                   opt                   usr
dir13                   proc                  ut2
dir2                    rhome                 var
dir3                    root
[root@samba /]# ./judgedfl.sh
input link:mnt
mnt is a link
mnt is useful
[root@samba /]# ls -l /mnt
总用量 696
-rw-r--r--  3 root root     14 1030 2020 CentOS_BuildTag
drwxr-xr-x  3 root root   2048 1027 2020 EFI
-rw-rw-r-- 21 root root    227 830 2017 EULA
-rw-rw-r-- 21 root root  18009 1210 2015 GPL
drwxr-xr-x  3 root root   2048 1027 2020 images
drwxr-xr-x  2 root root   2048 113 2020 isolinux
drwxr-xr-x  2 root root   2048 1027 2020 LiveOS
drwxr-xr-x  2 root root 673792 114 2020 Packages
drwxr-xr-x  2 root root   4096 114 2020 repodata
-rw-rw-r-- 21 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 21 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--  1 root root   2883 114 2020 TRANS.TBL
[root@samba /]# ls -l ll
lrwxrwxrwx 1 root root 4 816 11:34 ll -> dir2
[root@samba /]#
[root@samba /]# ./judgedfl.sh
input link:homw
[root@samba /]# ./judgedfl.sh
input link:home
home is a link
home is useful
[root@samba /]#
[root@samba /]# ./judgedfl.sh
input link:dir11
dir11 is a link
dir11 is useful
[root@samba /]#

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

[root@samba caozx26]# if [ -!e $link ];then
if [ -echo $link $link ];then

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

[root@nfs ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)
[root@nfs ~]# echo $?
3

在这里插入图片描述

[root@nfs ~]# cat /etc/selinux/config# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted[root@nfs ~]# cat /etc/selinux/config |tr 'enabled' 'disabled'# This fibl coitrobs thl ststl of SELiiux oi thl systlm.
# SELINUX= csi tskl oil of thlsl thrll vsbuls:
#     liforciig - SELiiux slcurity pobicy is liforcle.
#     plrmissivl - SELiiux priits wsriiigs iistlse of liforciig.
#     eissable - No SELiiux pobicy is bosele.
SELINUX=eissable
# SELINUXTYPE= csi tskl oil of thrll vsbuls:
#     tsrgltle - Tsrgltle proclssls srl protlctle,
#     miiimum - Moeificstioi of tsrgltle pobicy. Oiby slblctle proclssls srl protlctle.
#     mbs - Mubti Llvlb Slcurity protlctioi.
SELINUXTYPE=tsrgltle

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

[root@web ~]# echo $[$RANDOM%131]
42
您在 /var/spool/mail/root 中有邮件

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

[root@web ~]# echo $[$RANDOM%900+100]
392

在这里插入图片描述

[root@web ~]# tr [] [*] <lucky1.txt
139     7630
139     0185
139     0702
139     3305
139     5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr [ ] [*]<lucky1.txt
tr: 额外的操作数 "[*]"
Try 'tr --help' for more information.
[root@web ~]# tr [ ] ["*"]<lucky1.txt
tr: 额外的操作数 "[*]"
Try 'tr --help' for more information.
[root@web ~]# tr [ ] ‘*’ <lucky1.txt
tr: 额外的操作数 "‘*’"
Try 'tr --help' for more information.
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr ‘ ’ ‘*’ <lucky1.sh
-bash: lucky1.sh: 没有那个文件或目录
[root@web ~]# tr ‘ ’ ‘*’ <lucky1.txt
tr: 额外的操作数 "‘*’"
[root@web ~]# tr ' ' '*' <lucky1.txt
139     7630
139     0185
139     0702
139     3305
139     5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]#

在这里插入图片描述

Try 'tr --help' for more information.
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr '\t' '****' < lucky1.txt
139*7630
139*0185
139*0702
139*3305
139*5098
您在 /var/spool/mail/root 中有邮件

在这里插入图片描述

shell

ntp同步

[root@samba caozx26]# cat nntp.sh
count=0
ntp_server=192.168.235.100
while true
do
ntpdate -u $ntp_server >/dev/null 2>&1
if [ $? -ne 0 ];then
echo "failed" | mail -s "f" root@samba.web.cn
else
let count++
if [ $((count%100)) -eq 0 ];then
echo “successfully” |mail -s "su" root@samba.web.cn && count=0
fi
fi
done
[root@samba caozx26]# ./nntp.sh

until user

[root@samba rhome]# cat s2.sh
i=1
until [ $i -gt 10 ]
do
if [ $i -le 5 ];then
useradd -u 199$i df$i
else
mkdir -p /rhome/199$i
useradd -d /rhome/199$i dfs$i
fi
let i++
done
[root@samba rhome]# chmod +x s2.sh
[root@samba rhome]# ./s2.sh
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@samba rhome]# tail -19 /etc/passwd
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

judge /tmp/run

[root@samba rhome]# cat judged.sh
find /tmp/run
if [ $? -eq 0 ];then
rm -rf /tmp/run/*
else
mkdir -p /tmp/run
fi[root@samba rhome]# chmod +x judged.sh
[root@samba rhome]# ./judged.sh
/tmp/run

judge document file link

[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ ! -e $link ];then
echo "$link is not existed"
exit 1
fiif [ -d $link ];then
echo "$link is a document"
fiif [ -f $link ];then
echo "$link is a file"
fiif [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:home
home is a document
[root@samba /]# ./judgedfl.sh
input link:file11
file11 is not existed
[root@samba /]# ls
a3                      etc                   run
aa3                     home                  s2.sh
aa4                     httpd-2.4.37          samba
aa5                     httpd-2.4.37.tar.bz2  sbin
aa6                     ifdfl.sh              shell01
app                     ipping.sh             shop
apr-1.5.2               judgedfl.sh           srv
apr-1.5.2.tar.bz2       lib                   synatx.sh
apr-util-1.5.4.tar.bz2  lib64                 sys
bin                     lk                    tmp
boot                    ll                    u01
cmake.sh                media                 u02
dev                     mnt                   u1
dir1                    mysql-5.6.31          u2
dir11                   mysql-5.6.31.tar.gz   u3
dir12                   opt                   usr
dir13                   proc                  ut2
dir2                    rhome                 var
dir3                    root
[root@samba /]# ./judgedfl.sh
input link:dir12
dir12 is a file
[root@samba /]# ./judgedfl.sh
input link:aa5
aa5 is a file

pingok mail

[root@samba /]# cat pingpo.sh
read -p "pl input a ip:" ip
ping -c1 -w1 $ip
if [ $? -ne 0 ];then
echo "server $ip is down"
echo "$ip no"|mail -s "$ip no" root@sambe.web.cn
else
echo "server $ip is up"
echo "$ip ok"|mail -s "$ip ok" root@sambe.web.cn
fi[root@samba /]# chmod +x pingpo.sh
[root@samba /]# ./pingpo.sh
pl input a ip:192.179.231.3
PING 192.179.231.3 (192.179.231.3) 56(84) bytes of data.--- 192.179.231.3 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999msserver 192.179.231.3 is down
[root@samba /]# cat /var/spool/mail/root
From root@code.itcast.cn  Thu May 15 19:32:19 2025
Return-Path: <root@code.itcast.cn>
X-Original-To: root
Delivered-To: root@code.itcast.cn
Received: by code.itcast.cn (Postfix, from userid 0)id 190B921C857D; Thu, 15 May 2025 19:32:19 +0800 (CST)
To: root@code.itcast.cn
From: code@code.itcast.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for code.itcast.cn ***
Message-Id: <20250515113219.190B921C857D@code.itcast.cn>
Date: Thu, 15 May 2025 19:32:19 +0800 (CST)
Status: ROcode.itcast.cn : May 15 19:32:18 : code : user NOT in sudoers ; TTY=pts/2 ;                                                              PWD=/home/code ; USER=root ; COMMAND=/bin/suFrom root@code.itcast.cn  Thu May 15 22:04:16 2025
Return-Path: <root@code.itcast.cn>
X-Original-To: root
Delivered-To: root@code.itcast.cn
Received: by code.itcast.cn (Postfix, from userid 0)id 290BA21C8591; Thu, 15 May 2025 22:04:16 +0800 (CST)
To: root@code.itcast.cn
From: code@code.itcast.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for code.itcast.cn ***
Message-Id: <20250515140416.290BA21C8591@code.itcast.cn>
Date: Thu, 15 May 2025 22:04:16 +0800 (CST)
Status: ROcode.itcast.cn : May 15 22:04:16 : code : user NOT in sudoers ; TTY=pts/2 ;                                                              PWD=/home/code ; USER=root ; COMMAND=/bin/suFrom root@web.cn  Sat Jun 21 11:51:59 2025
Return-Path: <root@web.cn>
X-Original-To: root
Delivered-To: root@web.cn
Received: by web.cn (Postfix, from userid 0)id 235A420446EA; Sat, 21 Jun 2025 11:51:59 +0800 (CST)
To: root@web.cn
From: code@web.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for web.cn ***
Message-Id: <20250621035159.235A420446EA@web.cn>
Date: Sat, 21 Jun 2025 11:51:59 +0800 (CST)
Status: Oweb.cn : Jun 21 11:51:59 : code : user NOT in sudoers ; TTY=pts/3 ; PWD=/hom                                                             e/code ; USER=root ; COMMAND=/bin/suFrom root@web.cn  Sat Jun 21 20:25:14 2025
Return-Path: <root@web.cn>
X-Original-To: root
Delivered-To: root@web.cn
Received: by web.cn (Postfix, from userid 0)id 5E4F020446E9; Sat, 21 Jun 2025 20:25:14 +0800 (CST)
To: root@web.cn
From: code@web.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for web.cn ***
Message-Id: <20250621122514.5E4F020446E9@web.cn>
Date: Sat, 21 Jun 2025 20:25:14 +0800 (CST)
Status: Oweb.cn : Jun 21 20:25:14 : code : user NOT in sudoers ; TTY=pts/1 ; PWD=/hom                                                             e/code ; USER=root ; COMMAND=/bin/su
--5C41D2044E8A.1755402895/samba.web.cn
Content-Description: Delivery report
Content-Type: message/delivery-statusReporting-MTA: dns; samba.web.cn
X-Postfix-Queue-ID: 5C41D2044E8A
X-Postfix-Sender: rfc822; root@samba.web.cn
Arrival-Date: Sun, 17 Aug 2025 11:54:54 +0800 (CST)Final-Recipient: rfc822; root@sambe.web.cn
Action: failed
Status: 5.4.4
Diagnostic-Code: X-Postfix; Host or domain name not found. Name service erro                                                             rfor name=sambe.web.cn type=AAAA: Host not found--5C41D2044E8A.1755402895/samba.web.cn
Content-Description: Undelivered Message
Content-Type: message/rfc822Return-Path: <root@samba.web.cn>
Received: by samba.web.cn (Postfix, from userid 0)id 5C41D2044E8A; Sun, 17 Aug 2025 11:54:54 +0800 (CST)
Date: Sun, 17 Aug 2025 11:54:54 +0800
To: root@sambe.web.cn
Subject: 192.179.231.3 no
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20250817035454.5C41D2044E8A@samba.web.cn>
From: root@samba.web.cn (root)192.179.231.3 no--5C41D2044E8A.1755402895/samba.web.cn--[root@samba /]# cat pingpo.sh
read -p "pl input a ip:" ip
ping -c1 -w1 $ip
if [ $? -ne 0 ];then
echo "server $ip is down"
echo "$ip no"|mail -s "$ip no" root@sambe.web.cn
else
echo "server $ip is up"
echo "$ip ok"|mail -s "$ip ok" root@sambe.web.cn
fi[root@samba /]# ./pingpo.sh
pl input a ip:192.168.235.254
PING 192.168.235.254 (192.168.235.254) 56(84) bytes of data.
64 bytes from 192.168.235.254: icmp_seq=1 ttl=128 time=0.744 ms--- 192.168.235.254 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.744/0.744/0.744/0.000 ms
server 192.168.235.254 is up
[root@samba /]# tail -10 /var/spool/mail/root
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20250817040023.7969E2044E8B@samba.web.cn>
From: root@samba.web.cn (root)192.168.235.254 ok

program

[root@samba home]# cat program.sh
read -p "please input a synatx " jj
if [ -z $jj ];then
echo "usage:/home/program hello or world"
exit 1
fi
if [ $jj == hello ];then
echo "world"
fi
if [ $jj == world ];then
echo "hello"
fi
if [ $jj != hello ]&&[ $jj != world ];then
echo "usage:/home/program hello or world"
fi
[root@samba home]# chmod +x program.sh
[root@samba home]# ./program.sh
please input a synatx hell
usage:/home/program hello or world
[root@samba home]# ./program.sh
please input a synatx wo
usage:/home/program hello or world
[root@samba home]# ./program.sh
please input a synatx
usage:/home/program hello or world
[root@samba home]# ./program.sh
please input a synatx l;
usage:/home/program hello or world

NFS 搭建

[root@nfs ~]# cat nfs.sh
systemctl status firewalld >/dev/null 2>&1
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0 >/dev/null 2>&1
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config >/dev/null 2>&1
fi
rpm -qa | grep rpcbind >/dev/null 2>&1
if [ $? -ne 0 ];then
yum install rpcbind -y
fi
rpm -qa | grep nfs-utils>/dev/null 2>&1
if [ $? -ne 0 ];then
yum install nfs-utils -y
fi
cat /etc/exports |grep -v ^#
if [ $? -ne 0 ];then
echo "/share 192.168.235.0/24(rw,sync)" >>/etc/exports
fi
systemctl start rpcbind
systemctl start nfs-utils
ss -ntltp|grep 111
if [ $? -eq 0 ];then
echo "nfs has been started"
fi
[root@nfs ~]# ./nfs.sh
/share 192.168.235.0/24(rw,sync)
LISTEN     0      128          *:111                      *:*                   users:(("rpcbind",pid=721,fd=8))
LISTEN     0      128          *:22                       *:*                   users:(("sshd",pid=1115,fd=3))
LISTEN     0      128       [::]:111                   [::]:*                   users:(("rpcbind",pid=721,fd=11))
LISTEN     0      32        [::]:21                    [::]:*                   users:(("vsftpd",pid=1119,fd=4))
LISTEN     0      128       [::]:22                    [::]:*                   users:(("sshd",pid=1115,fd=4))
nfs has been started
[root@nfs ~]#

random phonenumber

[root@web ~]# cat num.sh
a=139
i=0
while [ $i -lt 1000 ]
do
echo $a$[$RANDOM%90000000+10000000]>>phonenum.txt
let i++
done
[root@web ~]# cat phonenum.txt
13910004559
13910029040
13910010475
13910000223
13910020228
13910009012

lucky ad

[root@web ~]# cat luck.sh
cat phonenum.txt|sort -R|grep -A 5 num|grep -v ^“num.txt”>luvk.txt
cat luvk.txt|cut -c1-3 >he.txt
cat luvk.txt|cut -c8-11 >ta.txt
paste he.txt ta.txt > pa.txt
sed 's/[[:space:]]/****/g' pa.txt >luad.txt
[root@web ~]# ./luck.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat luad.txt
139****3617
139****3525
139****7644
139****6141
139****4299

记录

192.168.235.10

    │                 • 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 16 22:32:34 2025 from 192.168.235.1
[code@samba ~]$ su - caozx26
密码:
上一次登录:六 816 19:33:36 CST 2025pts/1 上
[caozx26@samba ~]$ sudo su
[sudo] caozx26 的密码:
[root@samba caozx26]# ntpdate -u 192.168.235.100
17 Aug 08:11:20 ntpdate[47238]: adjust time server 192.168.235.100 offset 0.000247 sec
[root@samba caozx26]# vim ntp.sh
[root@samba caozx26]# vim ntpdate.sh
[root@samba caozx26]# vim nntp.sh
[root@samba caozx26]# cat nntp.sh
count=0
ntp_server=192.168.235.100
while true
do
ntpdate -u $ntp_server >/dev/null 2>&1
if[ $? -ne 0 ];then
echo "failed" | mail -s "f" root@samba.web.cn
else
let count++
if [ $((count%100)) -eq 0 ];then
echo “successfully” |mail -s "su" root@samba.web.cn && count=0
fi
fi
done
[root@samba caozx26]# chmod +x nntp.sh
[root@samba caozx26]# ./nntp.sh
./nntp.sh:行6: 未预期的符号 `then' 附近有语法错误
./nntp.sh:行6: `if[ $? -ne 0 ];then'
[root@samba caozx26]# vim nntp.sh
[root@samba caozx26]# cat nntp.sh
count=0
ntp_server=192.168.235.100
while true
do
ntpdate -u $ntp_server >/dev/null 2>&1
if [ $? -ne 0 ];then
echo "failed" | mail -s "f" root@samba.web.cn
else
let count++
if [ $((count%100)) -eq 0 ];then
echo “successfully” |mail -s "su" root@samba.web.cn && count=0
fi
fi
done
[root@samba caozx26]# ./nntp.sh
^C[root@samba caozx26]# vim until1.sh
[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ];then
let count++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stu$i
fi
[root@samba caozx26]# chmod +x until1.sh
[root@samba caozx26]# ./until1.sh
./until1.sh:行2: 未预期的符号 `then' 附近有语法错误
./until1.sh:行2: `until [ $i -gt 10 ];then'
[root@samba caozx26]# vim until1.sh
[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ];then
do
let count++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stu$i
fi
done
[root@samba caozx26]# ./until1.snh
bash: ./until1.snh: 没有那个文件或目录
[root@samba caozx26]# ./until1.sh
./until1.sh:行2: 未预期的符号 `then' 附近有语法错误
./until1.sh:行2: `until [ $i -gt 10 ];then'
[root@samba caozx26]# vim until1.sh
[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ]
do
let count++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stu$i
fi
done
[root@samba caozx26]# ./until1.sh
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
useradd:用户“stu0”已存在
^C[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ]
do
let count++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stu$i
fi
done
[root@samba caozx26]# vim until1.sh
[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ]
do
let i++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stu$i
fi
done
[root@samba caozx26]# vim until1.sh
'[root@samba caozx26]# cat until1.sh
i=0
until [ $i -gt 10 ]
do
let i++
if [ $i -le 5 ];then
useradd -u 10$i stu$i
else
mkdir -p /rhome/stt$i
useradd -d /rhome/stt$i stt$i
fi
done
[root@samba caozx26]# ./until1.sh
useradd:用户“stu5”已存在
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@samba caozx26]# ls /rhome/stt1
ls: 无法访问/rhome/stt1: 没有那个文件或目录
[root@samba caozx26]# cd /rhome
[root@samba rhome]# ls
stt10  stt6  stt8  stu10  stu7  stu9    stuu6  stuu8
stt11  stt7  stt9  stu6   stu8  stuu10  stuu7  stuu9
[root@samba rhome]# tail -5 /etc/passwd
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
[root@samba rhome]# vim ss.sh
[root@samba rhome]# cat ss.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 122$i 122$i
i++
if [ $i -ge 6 ];then
mkdir -p /rhome/ss$i
useradd -d /rhome/ss$i ss$i
fi
done[root@samba rhome]# chmod +x ss.sh
[root@samba rhome]# ./ss.sh
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
useradd:无效的用户名“1221”
./ss.sh:行5: i++: 未找到命令
^C[root@samba rhome]# cat ss.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 122$i 122$i
i++
if [ $i -ge 6 ];then
mkdir -p /rhome/ss$i
useradd -d /rhome/ss$i ss$i
fi
done[root@samba rhome]# vim ss.sh
[root@samba rhome]# cat ss.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 122$i 122$i
let i++
if [ $i -ge 6 ];then
mkdir -p /rhome/ss$i
useradd -d /rhome/ss$i ss$i
fi
done[root@samba rhome]# ./ss.sh
useradd:无效的用户名“1221”
useradd:无效的用户名“1222”
useradd:无效的用户名“1223”
useradd:无效的用户名“1224”
useradd:无效的用户名“1225”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1226”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1227”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1228”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“1229”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:无效的用户名“12210”
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@samba rhome]# useradd 112
useradd:无效的用户名“112”
[root@samba rhome]# tail -5 /etc/passwd
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
[root@samba rhome]# vim ss.sh
[root@samba rhome]# cat ss.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 122$i r122$i
let i++
if [ $i -ge 6 ];then
useradd -d /rhome/ss$i ss$i
fi
done[root@samba rhome]# tail -10 /etc/passwwd
tail: 无法打开"/etc/passwwd" 读取数据: 没有那个文件或目录
[root@samba rhome]# tal -10 /etc/passwd
bash: tal: 未找到命令...
[root@samba rhome]# tail -10 /etc/passwd
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
[root@samba rhome]# vim s1.sh
[root@samba rhome]# cat s1.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 11$i k$i
if [ $i -gt 5 ];then
mkdir -p /rhome/l$i
useradd -d /rhome/l$i l$i
fi
i++
done[root@samba rhome]# chmod +x s1.sh
[root@samba rhome]# ./s1.sh
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
useradd:用户“k1”已存在
./s1.sh:行9: i++: 未找到命令
^C[root@samba rhome]# vim s1.sh
[root@samba rhome]# cat s1.sh
i=1
until [ $i -gt 10 ]
do
useradd -u 11$i k$i
if [ $i -gt 5 ];then
mkdir -p /rhome/l$i
useradd -d /rhome/l$i l$i
fi
let i++
done[root@samba rhome]# ./s1.sh
useradd:用户“k1”已存在
useradd:UID 113 并不唯一
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@samba rhome]# tail -20 /etc/passwd
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
[root@samba rhome]# vim s2.sh
[root@samba rhome]# cat s2.sh
i=1
until [ $i -gt 10 ]
do
if [ $i -le 5 ];then
useradd -u 199$i df$i
else
mkdir -p /rhome/199$i
useradd -d /rhome/199$i dfs$i
fi
let i++
done
[root@samba rhome]# chmod +x s2.sh
[root@samba rhome]# ./s2.sh
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@samba rhome]# tail -19 /etc/passwd
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
[root@samba rhome]# find /tmp/run
/tmp/run
[root@samba rhome]# echo[root@samba rhome]# find /tmp/run
/tmp/run
[root@samba rhome]# echo $?
0
[root@samba rhome]# find /tmp/l
find: ‘/tmp/l’: 没有那个文件或目录
[root@samba rhome]# echo $?
1
[root@samba rhome]# vim judged.sh
[root@samba rhome]# cat judged.sh
find /tmp/run
if [ $? -eq 0 ];then
rm -rf /tmp/run/*
else
mkdir -p /tmp/run
fi[root@samba rhome]# chmod +x judged.sh
[root@samba rhome]# ./judged.sh
/tmp/run
[root@samba rhome]# vim judgefdl.sh
[root@samba rhome]# cat judgefdl.sh
read -p "pl input link:" link
if [ -e $link ];then
if [ -e "readlink -f $link"]
[root@samba rhome]# read -p "ee" link
ee/rhome
[root@samba rhome]# if [ -e "readlink -f $link" ];then
> echo "ok"
> else
> echo "no"
> fi
no
[root@samba rhome]# ls
19910  1999         l6  s1.sh  ss6  ss.sh  stt7   stu6  stuu10  stuu9
1996   judged.sh    l7  s2.sh  ss7  stt10  stt8   stu7  stuu6
1997   judgefdl.sh  l8  ss10   ss8  stt11  stt9   stu8  stuu7
1998   l10          l9  ss11   ss9  stt6   stu10  stu9  stuu8
[root@samba rhome]# cd .
[root@samba rhome]# ls
19910  1999         l6  s1.sh  ss6  ss.sh  stt7   stu6  stuu10  stuu9
1996   judged.sh    l7  s2.sh  ss7  stt10  stt8   stu7  stuu6
1997   judgefdl.sh  l8  ss10   ss8  stt11  stt9   stu8  stuu7
1998   l10          l9  ss11   ss9  stt6   stu10  stu9  stuu8
[root@samba rhome]# cd /
[root@samba /]# ls
a3                      cmake.sh      httpd-2.4.37.tar.bz2  opt        sys
aa3                     dev           ifdfl.sh              proc       tmp
aa4                     dir1          ipping.sh             rhome      u01
aa5                     dir11         lib                   root       u02
aa6                     dir12         lib64                 run        u1
app                     dir13         lk                    samba      u2
apr-1.5.2               dir2          ll                    sbin       u3
apr-1.5.2.tar.bz2       dir3          media                 shell01    usr
apr-util-1.5.4.tar.bz2  etc           mnt                   shop       ut2
bin                     home          mysql-5.6.31          srv        var
boot                    httpd-2.4.37  mysql-5.6.31.tar.gz   synatx.sh
[root@samba /]# if [ -e "readlink -f $link" ];then
> echo "ok"
> else
> echo "no"
> fi
no
[root@samba /]# link=ll
[root@samba /]# if [ -e "readlink -f $link" ];then
> echo "ok"
> else
> echo "no"
> fi
no
[root@samba /]# ls -l ll
lrwxrwxrwx 1 root root 4 816 11:34 ll -> dir2
[root@samba /]# read -p "w" link
wll
[root@samba /]# if [ -e "readlink -f $link " ];then
> echo "ok"
> else
> echo “no”
> fi
“no”
[root@samba /]# vim s2.sh
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link" link
if [ -e $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
[root@samba /]# chmod +x judgedfl.sh
[root@samba /]# ./judgedfl.sh
input linkll
./judgedfl.sh:行9: 语法错误: 未预期的文件结尾
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ -e $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi
[root@samba /]# ./judgedfl.sh
input link:ll
ll is a link
ll is useful
[root@samba /]# ./judgedfl.sh
input link:/rhome
/rhome is a link
/rhome is useful
[root@samba /]# ls
a3                      etc                   run
aa3                     home                  s2.sh
aa4                     httpd-2.4.37          samba
aa5                     httpd-2.4.37.tar.bz2  sbin
aa6                     ifdfl.sh              shell01
app                     ipping.sh             shop
apr-1.5.2               judgedfl.sh           srv
apr-1.5.2.tar.bz2       lib                   synatx.sh
apr-util-1.5.4.tar.bz2  lib64                 sys
bin                     lk                    tmp
boot                    ll                    u01
cmake.sh                media                 u02
dev                     mnt                   u1
dir1                    mysql-5.6.31          u2
dir11                   mysql-5.6.31.tar.gz   u3
dir12                   opt                   usr
dir13                   proc                  ut2
dir2                    rhome                 var
dir3                    root
[root@samba /]# ./judgedfl.sh
input link:mnt
mnt is a link
mnt is useful
[root@samba /]# ls -l /mnt
总用量 696
-rw-r--r--  3 root root     14 1030 2020 CentOS_BuildTag
drwxr-xr-x  3 root root   2048 1027 2020 EFI
-rw-rw-r-- 21 root root    227 830 2017 EULA
-rw-rw-r-- 21 root root  18009 1210 2015 GPL
drwxr-xr-x  3 root root   2048 1027 2020 images
drwxr-xr-x  2 root root   2048 113 2020 isolinux
drwxr-xr-x  2 root root   2048 1027 2020 LiveOS
drwxr-xr-x  2 root root 673792 114 2020 Packages
drwxr-xr-x  2 root root   4096 114 2020 repodata
-rw-rw-r-- 21 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r-- 21 root root   1690 1210 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--  1 root root   2883 114 2020 TRANS.TBL
[root@samba /]# ls -l ll
lrwxrwxrwx 1 root root 4 816 11:34 ll -> dir2
[root@samba /]#
[root@samba /]# ./judgedfl.sh
input link:homw
[root@samba /]# ./judgedfl.sh
input link:home
home is a link
home is useful
[root@samba /]# ./judgedfl.sh
input link:dir11
dir11 is a link
dir11 is useful
[root@samba /]# ./judgedfl.sh
input link:home
home is a link
home is useful
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ -ne $link ];then
echo "$link is useless"
exit 1
fi
if [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:hos
./judgedfl.sh: 第 2 行:[: -ne: 期待一元表达式
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ -e $link ];then
echo "$link is useless"
exit 1
fi
if [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ -e $link ] && [ $? -ne 0 ];then
echo "$link useless"
exit 1
fi
if [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:hks
[root@samba /]# echo $link
ll
[root@samba /]# link=nks
[root@samba /]# echo $nks[root@samba /]# echo $?
0
[root@samba /]# echo $link
nks
[root@samba /]# if [ -e $link ];then
> echo "ok"
> else echo "no" fi
> fi
no fi
[root@samba /]# if [ -e $link ]&&[ $? -ne 0 ];then
> echo "wrong"
> exit 1
> fi
[root@samba /]# if [ -e $link ]&&[ $? -ne 0 ];then
> echo "wrong"
> fi
[root@samba /]# echo $link
nks
[root@samba /]# if [ -e $link ];then
> echo "ok"
> else echo "wrong"
> exit 1
> fi
wrong
exit
[caozx26@samba ~]$ if [ !e $link ];then
if [ exit $link ];then
> echo wrong
> exit 1
> fi
wrong
登出
[code@samba ~]$ su -caozx26
密码:
su: 鉴定故障
[code@samba ~]$ su - caozx26
密码:
上一次登录:日 817 08:08:58 CST 2025pts/4 上
[caozx26@samba ~]$ sudo su
[sudo] caozx26 的密码:
[root@samba caozx26]# if [ -!e $link ];then
if [ -echo $link $link ];then
> echo ^C
[root@samba caozx26]# if [ ! -e $link ];then
> echo "wrong"
> exit 1
> fi
[root@samba caozx26]# echo $link[root@samba caozx26]# link=lkl
[root@samba caozx26]# if [ ! -e $link ];then
> echo "wrong"
> exit 1
> fi
wrong
exit
[caozx26@samba ~]$ sudo su
[sudo] caozx26 的密码:
[root@samba caozx26]# ls
app         km  nntp.sh     ntp.sh     utilc.sh  视频  下载
find.sh     l2  ntp1.sh     until1.sh  公共      图片  音乐
inotify.sh  ll  ntpdate.sh  until.sh   模板      文档  桌面
[root@samba caozx26]# cd /
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ ! -e $link ] ;then
echo "$link useless"
exit 1
fi
if [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:sda
sda useless
[root@samba /]# ./judgedfl.sh
input link:home
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ ! -e $link ] ;then
echo "$link is out of efficient"
exit 1
fi
if [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:add
add is out of efficient
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ ! -e $link ] ;then
echo "$link is not existed"
exit 1
fi
if [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:dasd
dasd is not existed
[root@samba /]# ./judgedfl.sh
input link:ll
ll is a link
ll is useful
[root@samba /]# vim judgedfl.sh
[root@samba /]# cat judgedfl.sh
read -p "input link:" link
if [ ! -e $link ];then
echo "$link is not existed"
exit 1
fiif [ -d $link ];then
echo "$link is a document"
fiif [ -f $link ];then
echo "$link is a file"
fiif [ -L $link ];then
echo "$link is a link"
if [ -e $(readlink -f $link) ];then
echo "$link is useful"
else
echo "$link is useless"
fi
fi[root@samba /]# ./judgedfl.sh
input link:home
home is a document
[root@samba /]# ./judgedfl.sh
input link:file11
file11 is not existed
[root@samba /]# ls
a3                      etc                   run
aa3                     home                  s2.sh
aa4                     httpd-2.4.37          samba
aa5                     httpd-2.4.37.tar.bz2  sbin
aa6                     ifdfl.sh              shell01
app                     ipping.sh             shop
apr-1.5.2               judgedfl.sh           srv
apr-1.5.2.tar.bz2       lib                   synatx.sh
apr-util-1.5.4.tar.bz2  lib64                 sys
bin                     lk                    tmp
boot                    ll                    u01
cmake.sh                media                 u02
dev                     mnt                   u1
dir1                    mysql-5.6.31          u2
dir11                   mysql-5.6.31.tar.gz   u3
dir12                   opt                   usr
dir13                   proc                  ut2
dir2                    rhome                 var
dir3                    root
[root@samba /]# ./judgedfl.sh
input link:dir12
dir12 is a file
[root@samba /]# ./judgedfl.sh
input link:aa5
aa5 is a file
[root@samba /]# vim pingpo.sh
[root@samba /]# cat pingpo.sh
read -p "pl input a ip:" ip
ping -c1 -w1 $ip
if [ $? -ne 0 ];then
echo "server $ip is down"
echo "$ip no"|mail -s "$ip no" root@sambe.web.cn
else
echo "server $ip is up"
echo "$ip ok"|mail -s "$ip ok" root@sambe.web.cn
fi[root@samba /]# chmod +x pingpo.sh
[root@samba /]# ./pingpo.sh
pl input a ip:192.179.231.3
PING 192.179.231.3 (192.179.231.3) 56(84) bytes of data.--- 192.179.231.3 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999msserver 192.179.231.3 is down
[root@samba /]# cat /var/spool/mail/root
From root@code.itcast.cn  Thu May 15 19:32:19 2025
Return-Path: <root@code.itcast.cn>
X-Original-To: root
Delivered-To: root@code.itcast.cn
Received: by code.itcast.cn (Postfix, from userid 0)id 190B921C857D; Thu, 15 May 2025 19:32:19 +0800 (CST)
To: root@code.itcast.cn
From: code@code.itcast.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for code.itcast.cn ***
Message-Id: <20250515113219.190B921C857D@code.itcast.cn>
Date: Thu, 15 May 2025 19:32:19 +0800 (CST)
Status: ROcode.itcast.cn : May 15 19:32:18 : code : user NOT in sudoers ; TTY=pts/2 ;                                                              PWD=/home/code ; USER=root ; COMMAND=/bin/suFrom root@code.itcast.cn  Thu May 15 22:04:16 2025
Return-Path: <root@code.itcast.cn>
X-Original-To: root
Delivered-To: root@code.itcast.cn
Received: by code.itcast.cn (Postfix, from userid 0)id 290BA21C8591; Thu, 15 May 2025 22:04:16 +0800 (CST)
To: root@code.itcast.cn
From: code@code.itcast.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for code.itcast.cn ***
Message-Id: <20250515140416.290BA21C8591@code.itcast.cn>
Date: Thu, 15 May 2025 22:04:16 +0800 (CST)
Status: ROcode.itcast.cn : May 15 22:04:16 : code : user NOT in sudoers ; TTY=pts/2 ;                                                              PWD=/home/code ; USER=root ; COMMAND=/bin/suFrom root@web.cn  Sat Jun 21 11:51:59 2025
Return-Path: <root@web.cn>
X-Original-To: root
Delivered-To: root@web.cn
Received: by web.cn (Postfix, from userid 0)id 235A420446EA; Sat, 21 Jun 2025 11:51:59 +0800 (CST)
To: root@web.cn
From: code@web.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for web.cn ***
Message-Id: <20250621035159.235A420446EA@web.cn>
Date: Sat, 21 Jun 2025 11:51:59 +0800 (CST)
Status: Oweb.cn : Jun 21 11:51:59 : code : user NOT in sudoers ; TTY=pts/3 ; PWD=/hom                                                             e/code ; USER=root ; COMMAND=/bin/suFrom root@web.cn  Sat Jun 21 20:25:14 2025
Return-Path: <root@web.cn>
X-Original-To: root
Delivered-To: root@web.cn
Received: by web.cn (Postfix, from userid 0)id 5E4F020446E9; Sat, 21 Jun 2025 20:25:14 +0800 (CST)
To: root@web.cn
From: code@web.cn
Auto-Submitted: auto-generated
Subject: *** SECURITY information for web.cn ***
Message-Id: <20250621122514.5E4F020446E9@web.cn>
Date: Sat, 21 Jun 2025 20:25:14 +0800 (CST)
Status: Oweb.cn : Jun 21 20:25:14 : code : user NOT in sudoers ; TTY=pts/1 ; PWD=/hom                                                             e/code ; USER=root ; COMMAND=/bin/su
--5C41D2044E8A.1755402895/samba.web.cn
Content-Description: Delivery report
Content-Type: message/delivery-statusReporting-MTA: dns; samba.web.cn
X-Postfix-Queue-ID: 5C41D2044E8A
X-Postfix-Sender: rfc822; root@samba.web.cn
Arrival-Date: Sun, 17 Aug 2025 11:54:54 +0800 (CST)Final-Recipient: rfc822; root@sambe.web.cn
Action: failed
Status: 5.4.4
Diagnostic-Code: X-Postfix; Host or domain name not found. Name service erro                                                             rfor name=sambe.web.cn type=AAAA: Host not found--5C41D2044E8A.1755402895/samba.web.cn
Content-Description: Undelivered Message
Content-Type: message/rfc822Return-Path: <root@samba.web.cn>
Received: by samba.web.cn (Postfix, from userid 0)id 5C41D2044E8A; Sun, 17 Aug 2025 11:54:54 +0800 (CST)
Date: Sun, 17 Aug 2025 11:54:54 +0800
To: root@sambe.web.cn
Subject: 192.179.231.3 no
User-Agent: Heirloom mailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20250817035454.5C41D2044E8A@samba.web.cn>
From: root@samba.web.cn (root)192.179.231.3 no--5C41D2044E8A.1755402895/samba.web.cn--[root@samba /]# cat pingpo.sh
read -p "pl input a ip:" ip
ping -c1 -w1 $ip
if [ $? -ne 0 ];then
echo "server $ip is down"
echo "$ip no"|mail -s "$ip no" root@sambe.web.cn
else
echo "server $ip is up"
echo "$ip ok"|mail -s "$ip ok" root@sambe.web.cn
fi[root@samba /]# ./pingpo.sh
pl input a ip:192.168.235.254
PING 192.168.235.254 (192.168.235.254) 56(84) bytes of data.
64 bytes from 192.168.235.254: icmp_seq=1 ttl=128 time=0.744 ms--- 192.168.235.254 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.744/0.744/0.744/0.000 ms
server 192.168.235.254 is up
[root@samba /]# tail -10 /var/spool/mail/root
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20250817040023.7969E2044E8B@samba.web.cn>
From: root@samba.web.cn (root)192.168.235.254 ok--7969E2044E8B.1755403224/samba.web.cn--[root@samba /]# cd /home
[root@samba home]# ls
caozx26  df3  k10  k6  stu0  stu4    stuu2  stuu6  u01  u05
code     df4  k2   k7  stu1  stu5    stuu3  stuu7  u02  user01
df1      df5  k4   k8  stu2  stuu1   stuu4  stuu8  u03
df2      k1   k5   k9  stu3  stuu10  stuu5  stuu9  u04
[root@samba home]# vim program.sh
[root@samba home]# cat program.sh
read -p "please input a synatx " jj
if [ -z $jj ];then
echo "usage:/home/program hello or world"
exit 1
fi
if [ $jj == hello ];then
echo "world"
fi
if [ $jj == world ];then
echo "hello"
fi
if [ $jj != hello ]&&[ $jj != world ];then
echo "usage:/home/program hello or world"
fi
[root@samba home]# chmod +x program.sh
[root@samba home]# ./program.sh
please input a synatx hell
usage:/home/program hello or world
[root@samba home]# ./program.sh
please input a synatx wo
usage:/home/program hello or world
[root@samba home]# ./program.sh
please input a synatx
usage:/home/program hello or world
[root@samba home]# ./program.sh
please input a synatx l;
usage:/home/program hello or world
[root@samba home]#
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: Sun Aug 17 08:05:10 2025 from 192.168.235.1
[code@samba ~]

192.168.235.3

    ┌──────────────────────────────────────────────────────────────────────┐│                 • MobaXterm Personal Edition v23.2 •                 ││               (SSH client, X server and network tools)               ││                                                                      ││ ⮞ SSH session to root@192.168.235.3                                  ││   • 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 Jul 25 20:51:26 2025 from 192.168.235.1
[root@nfs ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)
[root@nfs ~]# echo $?
3
[root@nfs ~]# cat /etc/selinux/config# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted[root@nfs ~]# setenforce 0
setenforce: SELinux is disabled
[root@nfs ~]# echo $?
1
[root@nfs ~]# yum repoliar
已加载插件:fastestmirror, langpacks
没有该命令:repoliar。请使用 /usr/bin/yum --help
[root@nfs ~]# yum repolist
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
源标识                                         源名称                                                                       状态
!base/7/x86_64                                 CentOS-7 - Base - mirrors.aliyun.com                                         10,072
!epel/x86_64                                   Extra Packages for Enterprise Linux 7 - x86_64                               13,791
!extras/7/x86_64                               CentOS-7 - Extras - mirrors.aliyun.com                                          526
!updates/7/x86_64                              CentOS-7 - Updates - mirrors.aliyun.com                                       6,173
repolist: 30,562
[root@nfs ~]# yum repolist
已加载插件:fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
源标识                                         源名称                                                                       状态
!base/7/x86_64                                 CentOS-7 - Base - mirrors.aliyun.com                                         10,072
!epel/x86_64                                   Extra Packages for Enterprise Linux 7 - x86_64                               13,791
!extras/7/x86_64                               CentOS-7 - Extras - mirrors.aliyun.com                                          526
!updates/7/x86_64                              CentOS-7 - Updates - mirrors.aliyun.com                                       6,173
repolist: 30,562
[root@nfs ~]# yum install nfs
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
base                                                                                                       | 3.6 kB  00:00:00
epel                                                                                                       | 4.3 kB  00:00:00
extras                                                                                                     | 2.9 kB  00:00:00
updates                                                                                                    | 2.9 kB  00:00:00
没有可用软件包 nfs。
错误:无须任何处理
[root@nfs ~]# yum install npcbind
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
没有可用软件包 npcbind。
错误:无须任何处理
[root@nfs ~]# rpm -ql |grep rpcbind
rpm:未给出要查询的参数
[root@nfs ~]# rpm -qa |grep rpcbind
rpcbind-0.2.0-49.el7.x86_64
[root@nfs ~]# rpm -q rpcbind
rpcbind-0.2.0-49.el7.x86_64
[root@nfs ~]# rpm -qa nfs-utils
nfs-utils-1.3.0-0.68.el7.2.x86_64
[root@nfs ~]# echo $?
0
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq ]
[root@nfs ~]# systemctl start firewalld
[root@nfs ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: active (running) since 日 2025-08-17 16:01:03 CST; 6s agoDocs: man:firewalld(1)Main PID: 65426 (firewalld)Tasks: 2CGroup: /system.slice/firewalld.service└─65426 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid817 16:01:02 nfs.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
817 16:01:03 nfs.cn systemd[1]: Started firewalld - dynamic firewall daemon.
817 16:01:04 nfs.cn firewalld[65426]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configura...t now.
Hint: Some lines were ellipsized, use -l to show in full.
[root@nfs ~]# echo $?
0
[root@nfs ~]# systemctl stop firewalld
[root@nfs ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)817 16:01:02 nfs.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
817 16:01:03 nfs.cn systemd[1]: Started firewalld - dynamic firewall daemon.
817 16:01:04 nfs.cn firewalld[65426]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configura...t now.
817 16:01:37 nfs.cn systemd[1]: Stopping firewalld - dynamic firewall daemon...
817 16:01:38 nfs.cn systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@nfs ~]# echo $?
3
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# setenforce 0
setenforce: SELinux is disabled
[root@nfs ~]# echo $?
1
[root@nfs ~]# cat /etc/selinux/config# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted[root@nfs ~]# ls /etc/selinux/config
/etc/selinux/config
[root@nfs ~]# cat /etc/selinux/config# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted[root@nfs ~]# cat /etc/selinux/config |tr 'enabled' 'disabled'# This fibl coitrobs thl ststl of SELiiux oi thl systlm.
# SELINUX= csi tskl oil of thlsl thrll vsbuls:
#     liforciig - SELiiux slcurity pobicy is liforcle.
#     plrmissivl - SELiiux priits wsriiigs iistlse of liforciig.
#     eissable - No SELiiux pobicy is bosele.
SELINUX=eissable
# SELINUXTYPE= csi tskl oil of thrll vsbuls:
#     tsrgltle - Tsrgltle proclssls srl protlctle,
#     miiimum - Moeificstioi of tsrgltle pobicy. Oiby slblctle proclssls srl protlctle.
#     mbs - Mubti Llvlb Slcurity protlctioi.
SELINUXTYPE=tsrgltle[root@nfs ~]# vim /etc/selinux/config
[root@nfs ~]# sed 's/enabled/disabled/g' /etc/selinux/config# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0
if [ $? -eq 0 ];then[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config
fi
rpm -ql |grep rpcbind
if [ $? -eq 0 ];then[root@nfs ~]# rpm -ql|grep rpcbind
rpm:未给出要查询的参数
[root@nfs ~]# rpm -ql |grep rpcbind
rpm:未给出要查询的参数
[root@nfs ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-49.el7.x86_64
[root@nfs ~]# rpm -ql | grep rpcbind
rpm:未给出要查询的参数
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-49.el7.x86_64
ech[root@nfs ~]# echo $?
0
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config
fi
rpm -qa | grep rpcbind
if [ $? -ne 0 ];then
yum install rpcbind -y
fi
rpm -qa | grep nfs-utils
if [ $? -ne 0 ];then
yum install nfs-utils -y
fi
[root@nfs ~]# rpm -qa | grep nfs-utils
nfs-utils-1.3.0-0.68.el7.2.x86_64
[root@nfs ~]# echo $?
0
[root@nfs ~]# cat /etc/exports
/share 192.168.235.0/24(rw,sync)
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat /etc/exports |grep -v ^#
/share 192.168.235.0/24(rw,sync)
[root@nfs ~]# echo $?
0
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config
fi
rpm -qa | grep rpcbind
if [ $? -ne 0 ];then
yum install rpcbind -y
fi
rpm -qa | grep nfs-utils
if [ $? -ne 0 ];then
yum install nfs-utils -y
fi
cat /etc/exports |grep -v ^#
if [ $? -ne 0 ];then
echo /share 192.168.235.0/24(rw,sync) >>/etc/exports
fi
systemctl start rpcbind
systemctl start nfs-utils
ss -ntltp|grep 111
if [ $? -eq 0 ];then
echo "nfs has been started"
fi
[root@nfs ~]# chmod +x nfs.sh
[root@nfs ~]# ./nfs.sh
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)817 16:01:02 nfs.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
817 16:01:03 nfs.cn systemd[1]: Started firewalld - dynamic firewall daemon.
817 16:01:04 nfs.cn firewalld[65426]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configura...t now.
817 16:01:37 nfs.cn systemd[1]: Stopping firewalld - dynamic firewall daemon...
817 16:01:38 nfs.cn systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
setenforce: SELinux is disabled# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targetedrpcbind-0.2.0-49.el7.x86_64
nfs-utils-1.3.0-0.68.el7.2.x86_64
/share 192.168.235.0/24(rw,sync)
./nfs.sh:行20: 未预期的符号 `(' 附近有语法错误
./nfs.sh:行20: `echo /share 192.168.235.0/24(rw,sync) >>/etc/exports'
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config
fi
rpm -qa | grep rpcbind
if [ $? -ne 0 ];then
yum install rpcbind -y
fi
rpm -qa | grep nfs-utils
if [ $? -ne 0 ];then
yum install nfs-utils -y
fi
cat /etc/exports |grep -v ^#
if [ $? -ne 0 ];then
echo "/share 192.168.235.0/24(rw,sync)" >>/etc/exports
fi
systemctl start rpcbind
systemctl start nfs-utils
ss -ntltp|grep 111
if [ $? -eq 0 ];then
echo "nfs has been started"
fi
[root@nfs ~]# setenforce 0 >>/dev/null 2>&1
[root@nfs ~]# echo $?
1
[root@nfs ~]# rpm -qa |grep rpcbind >/dev/null 2>&1
[root@nfs ~]# echo $?
0
[root@nfs ~]# vim nfs.sh[已修改但尚未保存]
/bin/bash: q: 未找到命令Shell 已返回127请按 ENTER 或其它命令继续
[root@nfs ~]# cat nfs.sh
systemctl status firewalld
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0 >/dev/null 2>&1
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config
fi
rpm -qa | grep rpcbind >/dev/null 2>&1
if [ $? -ne 0 ];then
yum install rpcbind -y
fi
rpm -qa | grep nfs-utils>/dev/null 2>&1
if [ $? -ne 0 ];then
yum install nfs-utils -y
fi
cat /etc/exports |grep -v ^#
if [ $? -ne 0 ];then
echo "/share 192.168.235.0/24(rw,sync)" >>/etc/exports
fi
systemctl start rpcbind
systemctl start nfs-utils
ss -ntltp|grep 111
if [ $? -eq 0 ];then
echo "nfs has been started"
fi
[root@nfs ~]# ./nfs.sh
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)8月 17 16:01:02 nfs.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
8月 17 16:01:03 nfs.cn systemd[1]: Started firewalld - dynamic firewall daemon.
8月 17 16:01:04 nfs.cn firewalld[65426]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configura...t now.
8月 17 16:01:37 nfs.cn systemd[1]: Stopping firewalld - dynamic firewall daemon...
8月 17 16:01:38 nfs.cn systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted/share 192.168.235.0/24(rw,sync)
LISTEN     0      128          *:111                      *:*                   users:(("rpcbind",pid=721,fd=8))
LISTEN     0      128          *:22                       *:*                   users:(("sshd",pid=1115,fd=3))
LISTEN     0      128       [::]:111                   [::]:*                   users:(("rpcbind",pid=721,fd=11))
LISTEN     0      32        [::]:21                    [::]:*                   users:(("vsftpd",pid=1119,fd=4))
LISTEN     0      128       [::]:22                    [::]:*                   users:(("sshd",pid=1115,fd=4))
nfs has been started
[root@nfs ~]# vim nfs.sh
[root@nfs ~]# cat nfs.sh
systemctl status firewalld >/dev/null 2>&1
if [ $? -eq 0 ];then
systemctl stop firewalld
systemctl disable firewalld
fi
setenforce 0 >/dev/null 2>&1
if [ $? -eq 1 ];then
sed 's/enabled/disabled/g' /etc/selinux/config >/dev/null 2>&1
fi
rpm -qa | grep rpcbind >/dev/null 2>&1
if [ $? -ne 0 ];then
yum install rpcbind -y
fi
rpm -qa | grep nfs-utils>/dev/null 2>&1
if [ $? -ne 0 ];then
yum install nfs-utils -y
fi
cat /etc/exports |grep -v ^#
if [ $? -ne 0 ];then
echo "/share 192.168.235.0/24(rw,sync)" >>/etc/exports
fi
systemctl start rpcbind
systemctl start nfs-utils
ss -ntltp|grep 111
if [ $? -eq 0 ];then
echo "nfs has been started"
fi
[root@nfs ~]# ./nfs.sh
/share 192.168.235.0/24(rw,sync)
LISTEN     0      128          *:111                      *:*                   users:(("rpcbind",pid=721,fd=8))
LISTEN     0      128          *:22                       *:*                   users:(("sshd",pid=1115,fd=3))
LISTEN     0      128       [::]:111                   [::]:*                   users:(("rpcbind",pid=721,fd=11))
LISTEN     0      32        [::]:21                    [::]:*                   users:(("vsftpd",pid=1119,fd=4))
LISTEN     0      128       [::]:22                    [::]:*                   users:(("sshd",pid=1115,fd=4))
nfs has been started
[root@nfs ~]#

192.168.20

root@192.168.235.20's password:┌────────────────────────────────────────────────────────────────────┐│                        • MobaXterm 20.0 •                          ││            (SSH client, X-server and networking tools)             ││                                                                    ││ ➤ SSH session to root@192.168.235.20                               ││   • SSH compression : ✘                                            ││   • SSH-browser     : ✔                                            ││   • X11-forwarding  : ✔  (remote display is forwarded through SSH) ││   • DISPLAY         : ✔  (automatically set on remote server)      ││                                                                    ││ ➤ For more info, ctrl+click on help or visit our website           │└────────────────────────────────────────────────────────────────────┘Last login: Sun Aug 17 19:47:21 2025 from 192.168.235.1
[root@web ~]# cat lucky.txt|cut -c8-11 >>tail
[root@web ~]# cat tail
7630
0185
0702
3305
5098
7630
0185
0702
3305
5098
[root@web ~]# rm -rf tail
[root@web ~]# cat lucky.txt|cut -c8-11 >>tail
[root@web ~]# cat tail
7630
0185
0702
3305
5098
[root@web ~]# paste head tail
139     7630
139     0185
139     0702
139     3305
139     5098
您在 /var/spool/mail/root 中有新邮件
[root@web ~]# paste head tail >>lucky1.txt
[root@web ~]# cat lucky1.txt
139     7630
139     0185
139     0702
139     3305
139     5098
[root@web ~]# tr [ ] [*]<<lucky1.txt
> ^C
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr [] [*] <lucky1.txt
139     7630
139     0185
139     0702
139     3305
139     5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr [ ] [*]<lucky1.txt
tr: 额外的操作数 "[*]"
Try 'tr --help' for more information.
[root@web ~]# tr [ ] ["*"]<lucky1.txt
tr: 额外的操作数 "[*]"
Try 'tr --help' for more information.
[root@web ~]# tr [ ] ‘*’ <lucky1.txt
tr: 额外的操作数 "‘*’"
Try 'tr --help' for more information.
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr ‘ ’ ‘*’ <lucky1.sh
-bash: lucky1.sh: 没有那个文件或目录
[root@web ~]# tr ‘ ’ ‘*’ <lucky1.txt
tr: 额外的操作数 "‘*’"
Try 'tr --help' for more information.
[root@web ~]# tr ' ' '*' <lucky1.txt
139     7630
139     0185
139     0702
139     3305
139     5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr '\t''*'<lucky1.txt
tr: "\\t*" 后缺少操作数
当进行替换操作时必须给定两组字符串。
Try 'tr --help' for more information.
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr '\t' '*' <lucky1.sh
-bash: lucky1.sh: 没有那个文件或目录
[root@web ~]# tr '\t' '*' < lucky1.txt
139*7630
139*0185
139*0702
139*3305
139*5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr '\t''****' < lucky1.txt
tr: "\\t****" 后缺少操作数
当进行替换操作时必须给定两组字符串。
Try 'tr --help' for more information.
您在 /var/spool/mail/root 中有邮件
[root@web ~]# tr '\t' '****' < lucky1.txt
139*7630
139*0185
139*0702
139*3305
139*5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]# sed 's/[[:space:]]/****/g' lucky1.txt
139****7630
139****0185
139****0702
139****3305
139****5098
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ls
1828.txt                axel-2.4         ftpok.sh                   mysql-5.6.31.tar.gz  process1.sh   testfor2.sh  user.sh
1837.txt                axel-2.4.tar.gz  ftp.sh                     no.txt               process.sh    testfor3.sh  vsftpd1.sh
1.txt                   bb.conf          head                       null                 psok.sh       testfor4.sh  vsftpd2.sh
2-1.java                cc.conf          httpd-2.4.37               num.sh               readme7       testfor.sh   vsftpdins.sh
2.java                  classfi.sh       httpd-2.4.37.tar.bz2       ok                   readme.txt    uc.sh        vsftpdok.sh
=6                      code             id.sh                      okl                  serverOk.sh   uname2.sh    vsftpd.sh
alll1                   cuser1.sh        initial-setup-ks.cfg       phonenum.txt         service-s.sh  unameok.sh   vstest.sh
anaconda-ks.cfg         dir1             inotify-tools-3.13.tar.gz  phon.txt             Steam.dll     uname.sh     wordpress
app                     dn.sh            judgeprimeok.sh            php-7.2.17           stuc.sh       url.sh       wordpress-4.7.3-zh_CN.tar.gz
apr-1.5.2               file20.java      judgeprime.sh              php-7.2.17.tar.xz    sum.sh        ur.sh        yearok.sh
apr-1.5.2.tar.bz2       file23.java      lucky1.txt                 ping2.sh             tail          useradd1.sh
apr-util-1.5.4          for51.sh         lucky.txt                  ping.sh              test1.sh      useradd.sh
apr-util-1.5.4.tar.bz2  for5.sh          mysql-5.6.31               primeok.sh           testcfor.sh   userad.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat num.sh
a=139
i=0
while [ $i -lt 1000 ]
do
echo $a$[$RANDOM%90000000+10000000]>>phonenum.txt
let i++
done
[root@web ~]# cat phonenum.txt
13910004559
13910029040
13910010475
13910000223
13910020228
13910009012
13910017840
13910014343
13910025615
13910007374
13910008233
13910032705
13910002975
13910009356
13910027127
13910003880
13910014784
13910005930
13910019907
13910028377
13910010118
13910008908
13910018711
13910018102
13910004180
13910002891
13910011596
13910011245
13910031114
13910005702
13910032462
13910012091
13910001453
13910023714
13910014476
13910007593
13910026917
13910022807
13910019661
13910019404
13910003269
13910013554
13910008990
13910022213
13910025188
13910022523
13910022328
13910026226
13910000872
13910024357
13910020939
13910009457
13910010339
13910012194
13910024557
13910028218
13910027178
13910002072
13910001041
13910007562
13910028728
13910005957
13910026536
13910005721
13910000452
13910007727
13910023371
13910014544
13910001622
13910020779
13910009729
13910019416
13910011646
13910018602
13910019936
13910023866
13910020367
13910025067
13910014521
13910012077
13910021096
13910025397
13910027838
13910026044
13910030037
13910028183
13910020785
13910007395
13910017435
13910007322
13910005289
13910007576
13910013634
13910020014
13910027540
13910002125
13910006861
13910013361
13910008205
13910028521
13910010992
13910009053
13910024141
13910015914
13910001089
13910031244
13910028139
13910011314
13910020606
13910021837
13910020493
13910018614
13910027035
13910007171
13910010089
13910003726
13910023379
13910022489
13910008667
13910020760
13910019940
13910028180
13910014331
13910007569
13910017070
13910021241
13910011089
13910008852
13910018141
13910002542
13910009373
13910030717
13910018093
13910013960
13910029598
13910016893
13910002404
13910016967
13910005353
13910004855
13910019459
13910009903
13910026420
13910012680
13910010093
13910016391
13910013096
13910021679
13910032459
13910026689
13910020128
13910004187
13910032002
13910013262
13910016089
13910018128
13910014855
13910023008
13910019422
13910002637
13910007743
13910027786
13910031207
13910032015
13910001307
13910003154
13910032433
13910018892
13910007644
13910031848
13910015043
13910002110
13910021677
13910021458
13910021457
13910023617
13910022469
13910006242
13910009741
13910017284
13910024530
13910031904
13910015391
13910014537
13910027739
13910028625
13910017353
13910026722
13910020779
13910032374
13910008844
13910019363
13910026620
13910005061
13910017479
13910019083
13910008492
13910029387
13910009869
13910009266
13910010918
13910010600
13910003124
13910018746
13910015553
13910022397
13910011386
13910019093
13910022707
13910010487
13910018519
13910004983
13910018369
13910008147
13910002565
13910032351
13910020009
13910003008
13910002388
13910010846
13910008875
13910021864
13910028556
13910030701
13910007722
13910002750
13910026141
13910013733
13910009428
13910000407
13910012388
13910017315
13910008212
13910008640
13910029857
13910018501
13910024809
13910010199
13910023912
13910032560
13910028715
13910017346
13910018296
13910029332
13910030900
13910018063
13910006091
13910015500
13910011839
13910000323
13910013129
13910014522
13910030137
13910006309
13910009171
13910009342
13910030393
13910003846
13910032020
13910022347
13910022121
13910009151
13910011707
13910001947
13910031644
13910005144
13910021182
13910032000
13910024911
13910011604
13910014907
13910020151
13910010491
13910009952
13910031337
13910023818
13910025852
13910032519
13910019036
13910003331
13910003276
13910031997
13910000357
13910013839
13910026874
13910016824
13910025741
13910006660
13910022441
13910030210
13910016193
13910007876
13910011373
13910023345
13910007167
13910017106
13910013979
13910013901
13910017146
13910027458
13910028493
13910027094
13910015477
13910017878
13910006616
13910028389
13910021699
13910005664
13910016457
13910016952
13910016330
13910013308
13910011213
13910020274
13910005366
13910022975
13910021552
13910020187
13910023826
13910008644
13910031421
13910025205
13910003658
13910027034
13910020105
13910018677
13910028341
13910002891
13910002178
13910020247
13910011274
13910008124
13910003731
13910003043
13910010840
13910013663
13910009216
13910020811
13910023189
13910004252
13910013030
13910030521
13910023633
13910005702
13910010264
13910031523
13910027162
13910029693
13910016679
13910002375
13910028161
13910015174
13910005241
13910027173
13910029652
13910006496
13910005670
13910020859
13910009729
13910011148
13910014600
13910003162
13910008831
13910025554
13910005191
13910032752
13910005433
13910005673
13910006886
13910009325
13910011347
13910021007
13910009085
13910006668
13910018690
13910022885
13910010973
13910017022
13910003304
13910002160
13910005802
13910013593
13910020887
13910026153
13910016340
13910012048
13910008164
13910020812
13910008175
13910020394
13910023256
13910024206
13910023915
13910030718
13910008489
13910014589
13910006500
13910020646
13910024291
13910025800
13910013804
13910030305
13910011875
13910016494
13910008124
13910004960
13910013826
13910006276
13910008795
13910009891
13910029082
13910004766
13910008175
13910019203
13910032105
13910015178
13910007120
13910009803
13910020695
13910000559
13910007520
13910021523
13910031529
13910006134
13910025266
13910024666
13910027659
13910009207
13910027850
13910000156
13910022258
13910032527
13910030143
13910029966
13910006613
13910017266
13910007630
13910027301
13910014728
13910015407
13910002344
13910026678
13910000119
13910013023
13910011272
13910002870
13910019152
13910018318
13910025544
13910013496
13910027204
13910029308
13910019086
13910000106
13910022882
13910022296
13910002908
13910029941
13910023635
13910027752
13910017617
13910020997
13910006268
13910020806
13910031554
13910027114
13910020027
13910010818
13910008227
13910006140
13910025111
13910003467
13910018985
13910003525
13910010827
13910024602
13910010241
13910000783
13910005392
13910031833
13910026736
13910014560
13910009972
13910002093
13910031642
13910004915
13910011040
13910000583
13910017727
13910028100
13910002334
13910020297
13910006270
13910020698
13910022770
13910014158
13910002668
13910027398
13910011807
13910015086
13910007360
13910017726
13910017162
13910008115
13910018470
13910022300
13910005718
13910017154
13910002401
13910028147
13910006652
13910018930
13910028305
13910005085
13910017396
13910003027
13910007072
13910029812
13910016436
13910028255
13910020081
13910012633
13910030053
13910023605
13910029551
13910019928
13910027185
13910002372
13910031907
13910028833
13910012099
13910004100
13910016367
13910012807
13910009511
13910021317
13910009836
13910012077
13910027477
13910014261
13910010157
13910000331
13910005424
13910018502
13910003420
13910012447
13910013981
13910012541
13910022711
13910010176
13910027325
13910025064
13910031652
13910000185
13910013305
13910030756
13910020702
13910029664
13910012664
13910005943
13910015584
13910024434
13910021806
13910030850
13910030973
13910027822
13910022703
13910009450
13910013358
13910001812
13910021481
13910004454
13910000825
13910019047
13910024938
13910005872
13910008999
13910008509
13910030671
13910023302
13910007475
13910023729
13910009931
13910002392
13910013442
13910025673
13910018926
13910032550
13910022155
13910029613
13910012454
13910003546
13910013630
13910007035
13910020508
13910006757
13910008550
13910032395
13910011888
13910027258
13910004926
13910030361
13910031581
13910020976
13910002458
13910003147
13910011964
13910022658
13910006775
13910019150
13910025290
13910005986
13910019862
13910031632
13910001133
13910025941
13910002213
13910025219
13910010837
13910030753
13910024274
13910024409
13910000935
13910004472
13910008378
13910027101
13910024422
13910021253
13910011392
13910011519
13910030176
13910029641
13910018374
13910024312
13910008365
13910031956
13910029851
13910017875
13910028557
13910024831
13910010272
13910007763
13910013092
13910021144
13910012585
13910006321
13910024450
13910005680
13910021155
13910003672
13910028132
13910023036
13910025683
13910017299
13910009015
13910005063
13910009344
13910010259
13910005661
13910002510
13910023770
13910006176
13910005136
13910032604
13910007612
13910018465
13910012556
13910023059
13910029256
13910012196
13910029389
13910004667
13910004853
13910019453
13910005489
13910023360
13910009046
13910008303
13910005671
13910007827
13910025801
13910031057
13910028392
13910006529
13910008968
13910003220
13910006315
13910008337
13910014995
13910018858
13910029395
13910007300
13910027625
13910025599
13910011653
13910016526
13910032253
13910014739
13910005874
13910005001
13910022771
13910025017
13910030065
13910006157
13910014467
13910031336
13910027276
13910019602
13910012168
13910012276
13910006542
13910022692
13910011186
13910030151
13910032595
13910020921
13910027132
13910023829
13910027387
13910016629
13910029445
13910003883
13910030132
13910017589
13910029640
13910031230
13910028999
13910017919
13910015128
13910026121
13910003813
13910007648
13910011253
13910012516
13910026578
13910017408
13910003909
13910018764
13910030969
13910028767
13910006256
13910008688
13910013418
13910022956
13910030736
13910011068
13910003965
13910031149
13910006691
13910006405
13910016676
13910027352
13910016401
13910023047
13910011414
13910000879
13910013592
13910028081
13910010608
13910016827
13910030865
13910018650
13910004890
13910025303
13910016952
13910018184
13910013905
13910012080
13910021600
13910002323
13910025430
13910025896
13910026476
13910001315
13910003061
13910022247
13910004900
13910032476
13910025604
13910004626
13910009908
13910009010
13910024448
13910005296
13910029074
13910025155
13910020140
13910013598
13910004873
13910003848
13910003671
13910006141
13910015375
13910012550
13910024175
13910000566
13910020422
13910008401
13910011222
13910006070
13910003128
13910026403
13910024707
13910023242
13910015436
13910031147
13910009884
13910032593
13910019397
13910012589
13910023500
13910029231
13910002265
13910032439
13910019486
13910006646
13910003184
13910012407
13910011675
13910021110
13910027740
13910022495
13910007474
13910025713
13910005396
13910032380
13910011194
13910002233
13910026596
13910032533
13910004909
13910018339
13910016983
13910014298
13910008904
13910009482
13910024988
13910030764
13910022879
13910018753
13910010191
13910017505
13910024325
13910032689
13910006594
13910027158
13910004272
13910014854
13910015377
13910022473
13910001446
13910003330
13910011757
13910026928
13910005389
13910013771
13910020699
13910006641
13910015474
13910032739
13910019597
13910025098
13910010271
13910014165
13910019822
13910019506
13910006162
13910026048
13910029338
13910012295
13910017284
13910020011
13910009103
13910023066
13910000928
13910015984
13910026631
13910019773
13910007182
13910014137
13910022909
13910031565
13910015546
13910006651
13910032567
13910017675
13910008682
13910019890
13910008349
13910016954
13910017123
13910007547
13910012723
13910010711
13910009209
13910000460
13910006503
13910030347
13910017386
13910025700
13910011199
13910023335
13910007295
13910004549
13910030274
13910010337
13910016391
13910017008
13910004555
13910032576
13910002084
13910014604
13910004299
13910019503
13910026447
13910015675
13910011752
13910012911
13910028819
13910004525
13910014531
13910024251
13910029317
13910021793
13910013276
13910021700
13910023191
13910010513
13910019906
13910015826
13910027860
13910029125
13910027393
13910016186
13910017521
13910010125
13910022349
13910023582
13910024884
13910024747
13910018061
13910030856
13910028132
13910024196
13910023894
13910004286
13910024565
13910028204
13910020892
13910003141
13910022213
13910017506
13910011186
13910025178
13910015630
13910014786
13910019725
13910012140
13910007116
13910010236
13910023322
13910018389
13910007350
13910014139
13910013798
13910017531
13910017425
13910030335
13910018839
13910006901
13910027805
13910026343
13910008927
13910010777
13910009444
13910008983
13910031315
13910012997
13910026087
13910022238
13910023011
13910001232
13910010612
13910018994
13910030081
13910012262
13910025692
13910010579
13910024332
13910010932
13910023252
13910020310
13910019126
13910020294
13910022882
13910021026
13910027694
13910029878
13910030948
13910003812
13910015424
“num.txt”
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat phonenum.txt |sort -R |grep -B 5 num|grep -v ^"num.txt"
13910023345
13910018764
13910004873
13910003330
13910012541
“num.txt”
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat phonenum.txt |sort -R |grep -B 5 num|grep -v ^num
13910030753
13910019363
13910005289
13910005191
13910008205
“num.txt”
[root@web ~]# cat phonenum.txt |sort -R |grep -B 5 num|grep -v ^“num.txt”
13910017726
13910011604
13910009216
13910010608
13910010475
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim luck.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat luck.sh
cat phonenumber.txt|tr -R|grep -A 5 num|grep -v ^“num.txt”>luvk.txt
cat luvk.txt|cut -c1-3 >he.txt
cat luvk.txt|cut -c8-11 >ta.txt
paste he.txt ta.txt > pa.txt
sed 's/[[:space:]]/****/g' pa.txt >luad.txt
[root@web ~]# chmod +x luck.sh
[root@web ~]# ./luck.sh
cat: phonenumber.txt: 没有那个文件或目录
tr:无效选项 -- R
Try 'tr --help' for more information.
[root@web ~]# vim luck.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./luck.sh
cat: phonenumber.txt: 没有那个文件或目录
[root@web ~]# vim luck.sh
[root@web ~]# cat luck.sh
cat phonenum.txt|sort -R|grep -A 5 num|grep -v ^“num.txt”>luvk.txt
cat luvk.txt|cut -c1-3 >he.txt
cat luvk.txt|cut -c8-11 >ta.txt
paste he.txt ta.txt > pa.txt
sed 's/[[:space:]]/****/g' pa.txt >luad.txt
[root@web ~]# ./luck.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat luad.txt
139****3617
139****3525
139****7644
139****6141
139****4299
[root@web ~]#
http://www.xdnf.cn/news/1320049.html

相关文章:

  • 力扣438:找到字符串中所有的字母异位词
  • Django前后端交互实现用户登录功能
  • [python学习记录2]变量
  • 脉冲计数实现
  • Docker之自定义jkd镜像上传阿里云
  • 排列组合+数量+资料
  • 25. 能否创建一个包含可变对象的不可变对象
  • 编程算法实例-Armstrong数(阿姆斯特朗数)
  • IDE/去读懂STM32CubeMX 时钟配置图(有源/无源晶振、旁路/晶振模式、倍频/分频)
  • 负载测试与压力测试详解
  • Rust Async 异步编程(五):执行器和系统 I/O
  • Spring 创建 Bean 的 8 种主要方式
  • MXFP4量化:如何在80GB GPU上运行1200亿参数的GPT-OSS模型
  • 【SpringBoot】Swagger 接口工具
  • 如何在Windows系统中更改用户名(中文转英文全流程)
  • 云原生俱乐部-RH134知识点总结(2)
  • MySQL数据库备份与恢复
  • neo4j导入导出方法
  • 25年第十本【金钱心理学】
  • 半敏捷卫星观测调度系统的设计与实现
  • 《WINDOWS 环境下32位汇编语言程序设计》第3章 使用MASM
  • Effective C++ 条款46:需要类型转换时请为模板定义非成员函数
  • Critic-V: VLM Critics Help Catch VLM Errors in Multimodal Reasoning(CVPR 2025)
  • 飞算AI 3.2.0实战评测:10分钟搭建企业级RBAC权限系统
  • 【牛客刷题】求四个数的最小公约数:两种高效解法详解(枚举法和最大公约数法)
  • 华为云之Linux系统安装部署Tomcat服务器
  • 【技术博客】480p 老番 → 8K 壁纸:APISR × SUPIR × CCSR「多重高清放大」完全指南
  • YoloV9改进策略:Block改进-DCAFE,并行双坐标注意力机制,增强长程依赖与抗噪性-即插即用
  • 【Golang】:函数和包
  • HTTPS 配置与动态 Web 内容部署指南