美文网首页
shell脚本进阶和系统启动、内核管理

shell脚本进阶和系统启动、内核管理

作者: jamas | 来源:发表于2020-03-15 14:06 被阅读0次

    1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www

    #!/bin/bash
    #
    while read -p "please input username and homedir: " user homedir; do
        id $user &>/dev/null
        if [ ! $? -eq 0 ];then
            useradd $user -d $homedir &>/dev/null
            echo "$user add!"
        fi
        done
    

    2、使用expect实现自动登录系统。

    #!/bin/bash
    ip=$1
    user=$2
    password=$3
    expect <<EOF
    set timeout 20
    spawn ssh $user@$ip
    expect {
    "yes/no" { send "yes\n";exp_continue }
    "password" { send "$password\n" }
    }
    expect "]#" { send "echo 'hello world!'"}
    expect eof
    EOF
    

    3、简述linux操作系统启动流程

    wKiom1fVBELjXsvaAAUkuL83t2Q304.jpg

    4、破解centos7 密码。

    (1) 启动时任意键暂停启动,按e键进入编辑模式


    snipaste_20200314_185617.png
    snipaste_20200314_185659.png

    (2) 将光标移动linux16开始的行,改为rw init=/sysroot/bin/sh,按ctrl-x启动


    snipaste_20200314_185940.png
    (3) 切换根chroot /sysroot,修改密码passwd root,重启系统。
    snipaste_20200314_190258.png

    相关文章

      网友评论

          本文标题:shell脚本进阶和系统启动、内核管理

          本文链接:https://www.haomeiwen.com/subject/qwihehtx.html