1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www
read -p "pleae input username: " USERNAME read -p "please input homedir: " HOMEDIR id $USERNAME &>/dev/null if [ $? -eq 0 ] ;then echo "the user $USERNAME is exist" else useradd -d $HOMEDIR $USERNAME &>/dev/null echo tww | passwd --stdin $USERNAME &>/dev/null echo "the USER $USERNAME is created " fi
2、使用expect实现自动登录系统。
#!/usr/bin/expect spawn ssh 192.168.0.156 expect { "yes/no" { send "yes\n";exp_continue } "password" { send "tao123\n" } } interact
注意:以上的"yes/no" { 与 "password" { 之间是要有空格的
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:
1)启动时任意键暂停启动
2)按e键进入编辑模式
3)将光标移动linux16开始的行,在其后添加内核参数rd.break
4)按ctrl+x启动
5)mount –o remount,rw /sysroot
6)chroot /sysroot
7)passwd root
8)exit
9)reboot
方法2:
1)启动时任意键暂停启动
2)按e键进入编辑模式
3)将光标移动linux16开始的行,在其后添加 rw init=/sysroot/bin/sh
4)按ctrl+x启动
5)chroot /sysroot
6)passwd root
7)exit
8)reboot