1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www
[root@centos7 ~]#vim useradd4-2.sh
#!/usr/bin
if [ "$1" == "magedu" -a "$2" == "/www" ];then
if grep "^$1" /etc/password &> /dev/null;then
echo "user $1 is already"
else
useradd -d $2 $1
echo useradd finished
fi
else
echo please in put "magedu /www"
exit
fi
2、使用expect实现自动登录系统。
[root@centos7 /]#vim expect.sh
#!/usr/bin/expect
spawn ssh 192.168.159.129
expect {
"yes/no" {send "yes\n";exp_continue}
"password" {send "cwx081428\n"}
}
interact
#expect eof
3、简述linux操作系统启动流程
1.加载BIOS的硬件信息,获取第一个启动设备
2.读取第一个启动设备MBR的引导加载程序(grub)的启动信息
3.加载核心操作系统的核心信息,核心开始解压缩,并尝试驱动所有的硬件设备
4.核心执行init程序,并获取默认的运行信息
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键进入编辑模式,进入编辑模式后按上下键找到linux16这一行,并将ro 修改为rw init=/sysroot/bin/bash.
(3) 修改完成后,按ctrl-x启动,进入以下界面,开始破解:
chroot /sysroot 表示切根。
密码修改后输入exit 推出编辑模式,并重启系统(rebboot)