1.编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www
#!/bin/bash
if [ "$1" == "magedu" -a "$2" == "/www" ];then
id -u $1 &> /dev/null && echo "$1 is exists" || { useradd $1 -d $2 ; echo "User $1 is created , home is $2 ."; }
else
echo 'please input magedu and /www'
fi
#!/bin/bash
[ "$1" = "magedu" -a "$2" = "/www" ] || { echo input;exit 10 ;}
id -u $1 &> /dev/null && echo "$1 is exist" || { useradd $1 -d $2 ; echo "User $1 created , home is $2 ."; }
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" }
}
interact
EOF
#./ssh.sh 192.168.1.100 USERNAME PASSWOER
3.简述Linux操作系统启动流程
4.破解centos7密码
启动时任意键暂停启动
按e键进入编辑模式
将光标移动linux16开始的行,添加内核参数rd.break
按ctrl-x启动
mount –o remount,rw /sysroot
chroot /sysroot
passwd root
touch /.autorelabel(如果selinux没开启不需要此操作)
exit
reboot