shell腳本編寫及LINUX啓動流程、centOS密碼破解

1、編寫腳本,接受二個位置參數,magedu和/www,判斷系統是否有magedu,如果沒有則自動創建magedu用戶,並自動設置家目錄爲/www
#!/bin/bash
PW=$(tr -dc '[:alnum:]' </dev/urandom |head -c6)
while read -p "please input your [username] and [home directory]:" name dir ;do
if [ -z "$name" ] ;then
echo "Please enter the correct user and directory separated by spaces!"
elif [ -z "$dir" ];then
echo "Please enter the correct directory!"
elif $(id $name &> /dev/null);then
echo "$name already exist!"
elif $(useradd $name -d $dir &> /dev/null);then
echo $name is created!;echo 123456 |passwd --stdin $name &> /dev/null;echo -e "Username is $name\nHome directory at $dir\nPassord is $PW ";
exit 10;
else
echo "Failed to add user!Please check whether the parameters you entered are correct!"
fi
done
shell腳本編寫及LINUX啓動流程、centOS密碼破解
shell腳本編寫及LINUX啓動流程、centOS密碼破解

2、使用expect實現自動登錄系統。
#!/usr/bin/expect
set user root
set PASSWD 123456
set IP 192.168.43.106
set timeout 10
spawn ssh $user@$IP
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$PASSWD\n" }
}
interact
shell腳本編寫及LINUX啓動流程、centOS密碼破解

3、簡述linux操作系統啓動流程

1.加載BIOS的硬件信息,獲取第一個啓動設備
2.讀取第一個啓動設備MBR的引導加載程序(grub)的啓動信息
3.加載核心操作系統的核心信息,核心開始解壓縮,並嘗試驅動所有的硬件設備
4.核心執行init程序(centos7是systemd),並獲取默認的運行信息;
5.init程序執行/etc/rc.d/rc.sysinit文件
6.啓動核心的外掛模塊
7.init執行運行的各個批處理文件(scripts)
8.init執行/etc/rc.d/rc.local
9.執行/bin/login程序,等待用戶登錄
10.登錄之後開始以Shell控制主機

4、破解centos7 密碼。
1.首先在啓動的時候在這個界面上按“E"
shell腳本編寫及LINUX啓動流程、centOS密碼破解
2.進入之後方向鍵的下,找到“LANG=ZH-CN.UTF-8",在這個命令後面輸入“rd.break",完成之後按ctrl+X進入
shell腳本編寫及LINUX啓動流程、centOS密碼破解
3.進入這個輸入以下命令
shell腳本編寫及LINUX啓動流程、centOS密碼破解
4.重啓之後什麼都不用按,會有一個百分比讀取,等待完成。
5.輸入用戶名root,以及密碼.破解完成。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章