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,以及密码.破解完成。

猜你喜欢

转载自blog.51cto.com/14671983/2488052
今日推荐