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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。