新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

shell常用脚本-创新互联

前言

专业成都网站建设公司,做排名好的好网站,排在同行前面,为您带来客户和效益!创新互联公司为您提供成都网站建设,五站合一网站设计制作,服务好的网站设计公司,成都网站制作、成都做网站负责任的成都网站制作公司!

 网上收集整理,感谢老男孩及各路大神,经常看他们的博客和视频,脚本绝对是自己纯手打,有什么不足之处,还请各位大神指点。若觉得有侵权地方,请及时联系本人,本人立即删除!!

 再次感谢老男孩,虽然没报您的学习班,但是看过好多您出的视频和您的博客。人要懂得感恩,尽管不是您的学生!

部分题目链接:http://oldboy.blog.51cto.com/2561410/1632876


  1. 在/chbo/目录下批量创建以10个随机小写字母开头_固定字符串.html文件

[root@web ]# cat create_chbo.sh #!/bin/sh randpw(){  < /dev/urandom tr -dc a-z | head -c${1:-10}; echo; } [ ! -d /chbo ]&& mkdir -p /chbo for i in `seq 9` do   result=`randpw`   touch /chbo/${result}_chbo.html done [root@web ]# sh create_chbo.sh3    [root@web ]# ls /chbo/ arwyievjgn_chbo.html  eoxtksdqhl_chbo.html  jbtpvjadia_chbo.html bzkhbwtgmw_chbo.html  hhrptuucgr_chbo.html  mmfrghunuv_chbo.html dldpbwhdfz_chbo.html  ivfeekbiyf_chbo.html  uwqcaynijh_chbo.html

2. 批量改名,将上面文件中的chbo改为chboy

[root@web mianshi]# sh chname.sh  [root@web mianshi]# ls /chbo/     arwyievjgn_chboy.html  eoxtksdqhl_chboy.html  jbtpvjadia_chboy.html bzkhbwtgmw_chboy.html  hhrptuucgr_chboy.html  mmfrghunuv_chboy.html dldpbwhdfz_chboy.html  ivfeekbiyf_chboy.html  uwqcaynijh_chboy.html [root@web mianshi]# cat chname.sh  #!/bin/sh cd /chbo for f in `ls *.html` do   mv $f `echo $f|sed 's#\(.*\)_chbo.html#\1_chboy.html#g'` done

3.批量创建用户chbo01-chbo10,并给每个用户设定8位数的随机密码。

[root@web ]# cat creat_user.sh2 #!/bin/sh [ ! -d /chbo/ ]&& mkdir -p /chbo/ [ -f /chbo/passwd ]&& rm -f /chbo/passwd for i in `seq -w 1 10` do   password=`openssl rand -base64 6`   useradd chbo$i && echo $password |passwd --stdin chbo$i   echo "chbo$i  $password" >>/chbo/passwd done [root@web ]# sh creat_user.sh2                                  Changing password for user chbo01. passwd: all authentication tokens updated successfully. Changing password for user chbo02. passwd: all authentication tokens updated successfully. Changing password for user chbo03. passwd: all authentication tokens updated successfully. Changing password for user chbo04. passwd: all authentication tokens updated successfully. Changing password for user chbo05. passwd: all authentication tokens updated successfully. Changing password for user chbo06. passwd: all authentication tokens updated successfully. Changing password for user chbo07. passwd: all authentication tokens updated successfully. Changing password for user chbo08. passwd: all authentication tokens updated successfully. Changing password for user chbo09. passwd: all authentication tokens updated successfully. Changing password for user chbo10. passwd: all authentication tokens updated successfully. [root@web ]# cat /chbo/passwd  chbo01  Llkl7shd chbo02  29/JqICq chbo03  7/0puAlT chbo04  MR6mDzqE chbo05  hMureKFp chbo06  WpQar93p chbo07  u4v0Dx+3 chbo08  OY5FBbgy chbo09  JvCGq32D chbo10  8BDfbxvT [root@web mianshi]# su - chbo01 [chbo01@web ~]$ su - chbo07 Password:  [chbo07@web ~]$ logout [chbo01@web ~]$ logout [root@web ]#

批量删除

for i in `seq -w 1 10`;do userdel -r chbo$i;done

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文题目:shell常用脚本-创新互联
网页链接:http://www.wjwzjz.com/article/djcded.html
在线咨询
服务热线
服务热线:028-86922220
TOP