一、用shell腳本實現自動登陸機器nginx
#!/usr/bin/expect set usr root set pwd 123456 set ipadd 10.0.0.203 spawn ssh $usr@$ipadd expect { "yes/no" { send "yes\n";exp_continue } "password" { send "$pwd\n" } } interact
二、shell 判斷一個值bone是否在數組arrayZ=( one two three four five five )中shell
#!/bin/bash arrayZ=( one two three four five five bond ) for i in `seq ${#arrayZ[*]}`;do echo ${arrayZ[$i-1]} if [ ${arrayZ[$i-1]} == bond ];then echo bond in arrayZ else echo bond not in arrayZ fi done
三、用命令或者腳本實現 0057AF051EFF 變爲 00:57:AF:05:1E:FF 。vim
#!/bin/bash Mac=0057AF051EFF for i in `seq 0 2 10`;do if [ $i -eq 2 ];then echo -n "${Mac:$i:2}" else echo -n "${Mac:$i:2}:" fi done
echo ${Mac:0:2}:${Mac:2:2}:${Mac:4:2}:${Mac:6:2}:${Mac:8:2}:${Mac:10}
四、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位密碼的腳本centos
#!/bin/bash declare -a num num=(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 let i=$[$RANDOM%${#num[*]}] echo -e "${num[$i]:0:20}\c" done
五、詳細敘述centos7開機流程數組
POST --> Boot Sequence --> Bootloader --> kernel + initramfs(initrd) --> rootfs --> /sbin/init init: CentOS 5 SysV init CentOS 6 Upstart CentOS 7 Systemd CentOS7引導順序 UEFi或BIOS初始化,運行POST開機自檢 選擇啓動設備 引導裝載程序, centos7是grub2 加載裝載程序的配置文件: /etc/grub.d/ /etc/default/grub /boot/grub2/grub.cfg 加載initramfs驅動模塊 加載內核選項 內核初始化,centos7使用systemd代替init 執行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須要的服務
六、編寫Nginx的systemd配置文件, 實現nginx進程開機啓動bash
vim /etc/systemd/system/nginx.service [Unit] Description=nginx After=network.target Documentation=man:nginx(8) [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