摘要:本篇文章探讨了大数据技术之shell脚本学习,希望阅读本篇文章以后大家有所收获,帮助大家对相关内容的理解更加深入。
本篇文章探讨了大数据技术之shell脚本学习,希望阅读本篇文章以后大家有所收获,帮助大家对相关内容的理解更加深入。
"
1、用shell脚本实现自动登陆机器
#!/bin/expect
set ip 192.168.109.128
set user root
set password redhat
set timeout 20
spawn ssh $user@$ip
expect {
""yes/no"" { send ""yes\n"";exp_continue }
""password"" { send ""$password\n"" }
}
interact
2、shell 判断一个值bone是否在数组arrayZ=( one two three four five five )中
arrayZ=( one two three four five six )
for i in $(seq ${#arrayZ[*]});
do
echo ${arrayZ[$i-1]}
if [ ""bone"" == ""${arrayZ[$i-1]}"" ];then
echo 'bone in array'
fi
done
3、用命令或者脚本实现 0057AF051EFF 变为 00:57:AF:05:1E:FF 。
ss=""0057AF051EFF""
len=$(expr length ${ss})
for i in $(seq 0 2 $[$len-2]);do
if [ $i -eq 0 ];then
echo -n ${ss:i:2}
else
echo -n :${ss:i:2}
fi
done
echo
4、a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 ! \@ # \$ \% \^ \& * ( ) - _ \= + \ \/ \' \"" \; \: [ ] { } \, . \?
用以上字符,结合数组,实现一个随机生成20位密码的脚本
ss=(a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9 0 ! \@ # \$ \% \^ \& * ( ) - _ \= + \ \/ \' \"" \; \: [ ] { } \, . \?)
for i in $(seq 20);do
lss=${#ss[*]}
ran=$[$RANDOM%89]
echo -n ""${ss[$ran]}""
done
echo
5、详细叙述centos7开机流程
post
MBR -grub1
grub2
kernel
加载initramfs
systemd
执行initrd.target所有单元,挂载/etc/fstab
从initramfs根文件系统切换到磁盘根目录
systemd执行默认target配置,配置文件/etc/systemd/system/default.target
systemd执行sysinit.target初始化系统及basic.target准备操作系统
systemd启动multi-user.target下的本机与服务器服务
systemd执行multi-user.target下的/etc/rc.d/rc.local
Systemd执行multi-user.target下的getty.target及登录服务
systemd执行graphical需要的服务
login
6、编写Nginx的systemd配置文件, 实现nginx进程开机启动
[Unit]
Description=nginx server daemon
Documentation=man:nginx(8)
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx1.8.1/sbin/nginx
ExecReload=/usr/local/nginx1.8.1/sbin/nginx -s reload
ExecStop=/usr/local/nginx1.8.1/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
" 本文由职坐标整理发布,学习更多的相关知识,请关注职坐标IT知识库!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号