第九周

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
[root@centos7 while]#sh while_read_useradd.sh
please input your [username] and [home directory]:magedu /www
magedu is created!
Username is magedu
Home directory at /www
Passord is 0TVpFQ 

第九周

~

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

第九周

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、啓動時任意鍵暫停啓動
2、按e鍵進入編輯模式

第九周

3、將光標移動linux16開始的行,添加內核參數rd.break
4、按ctrl-x啓動
第九周
5、系統根被掛載到/sysroot目錄下,且爲只讀掛載,需要重新掛載爲讀寫模式mount –o remount,rw /sysroot

第九周第九周

6、chroot /sysroot 切根
7、 使用passwd命令改免密passwd root
第九周
8、touch /.autorelabel
9、exit
10、reboot

方法二:
1、啓動時任意鍵暫停啓動 
2、按e鍵進入編輯模式 
3、將光標移動linux16開始的行,添加內核參數rd.break 
4、按ctrl-x啓動  
5、mount –o remount,rw  /sysroot 
6、vi /sysroot/etc/shadow   清空root密碼
7、reboot
之後就可以使用空密碼登錄系統,在修改密碼就可以了;

架構班作業:

1、使用dockerfile製作nginx+php-fpm鏡像,實現lnmp。

2、使用dockerfile製作tomcat鏡像,並實現對jsp測試頁訪問

3、安裝配置harbor服務,並將打包好的鏡像提交到harbor倉庫

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