美文网首页
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脚本进阶和系统启动、内核管理

    1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu...

  • [Linux]Shell

    shell:命令解释器,驱动linux内核;应用程序调用shell命令 1.Shell脚本的执行方式 脚本格式要求...

  • 2016.09.07 Linux shell脚本实战技术

    Linux shell脚本实战技术 一、shell介绍 shell是一个命令解释器,处于内核和用户之间,负责把用户...

  • Shell脚本面试题Top50

    Shell脚本面试题Top50 [TOC] 1:什么是Shell? Shell是用户和内核之间的接口。即使只有一个...

  • Android 进阶解密摘要

    参照《Android 进阶解密》做的摘要。 Android 系统启动过程 init 进程启动 Linux 内核加载...

  • Linux系统的Shell脚本传参(bash)2022-08-2

    Shell传参快速使用脚本 简便版 进阶版 getopt方法 getopts方法 做生信一般都绕不开Shell脚本...

  • 1.Shell脚本语言

    1.Shell介绍 shell是一种脚本语言,使用shell脚本可以访问操作系统的内核服务。 可以用于编译库。 s...

  • 系统启动和内核管理.

    cenos6启动流程 加载BIOS的硬件信息,获取第一个启动设备 读取第一个启动设备MBR的引导加载程序(grub...

  • 系统启动和内核管理

    一、Linux组成 二、CentOS6启动流程 三、启动流程 四、系统启动流程 init初始化 五、CentOS ...

  • shell学习笔记

    shell是基于shell解释器的脚本编程语言,也是使用Linux的常用工具,连接着用户和系统内核。 查看操作系统...

网友评论

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

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