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操作系统启动流程

4、破解centos7 密码。
(1) 启动时任意键暂停启动,按e键进入编辑模式


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

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

网友评论