1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www
vim useradd.sh
#!/bin/bash
read -p "please input a username:"USERNAME
read -p "please input homedir for user:"HOMEDIR
id $USERNAME &> /dev/null
if [ $? -eq 0 ];then
echo "$USERNAME already exists"
exit
else
useradd $USERNAME -d $HOMRDIR
echo "$USERNAME is created successfully"
fi
2、使用expect实现自动登录系统。
rpm -q expect
yum install expect
vim auto-ssh.exp
#!/usr/bin/expect
set ip [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set timeout 10
spawn ssh $user$ip
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n"}
}
interact
expect auto-ssh.exp 192.168.5.10 root 123456
3、简述linux操作系统启动流程 (此部分内容取自作者:苦逼运维)
4、破解centos7 密码。