1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www
[root@C76 sh]# cat ll.sh
#!/bin/bash
#
id $1 &>/dev/null
if [ $? -eq 0 ];then
echo user $1 is exist
else
useradd -d /www -m $1 &>/dev/null
echo user $1 is create
fi
执行脚本
[root@C76 sh]# sh ll.sh mage
[root@C76 sh]# cat /etc/passwd |tail -1
mage:x:1006:1006::/www:/bin/bash
2、使用expect实现自动登录系统。
[root@C76 sh]# cat expect.sh
#!/bin/bash
while read ip
do
user=root
password=redhat
expect <<EOF
set timeout 10
spawn ssh $user@$ip
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n" }
}
expect eof
EOF
done < ip.txt
#ip.txt放置要连接的ip
3、简述linux操作系统启动流程
centos6启动流程
1.加载BIOS的硬件信息,获取第一个启动设备 2.读取第一个启动设备MBR的引导加载程序(grub)的启动信息