Shell script writing and LINUX startup process, centOS password cracking

1. Write a script that accepts two location parameters, magedu and / www, to determine whether the system has magedu, if not, then automatically create a magedu user, and automatically set the home directory to / www
#! / Bin / bash
PW = $ (tr- dc '[: alnum:]' </ dev / urandom | head -c6)
while read -p "please input your [username] and [home directory]:" name dir; do
if [-z "$ name"]; then
echo "Please enter the correct user and directory separated by spaces!"
elif [-z "$ dir"]; then
echo "Please enter the correct directory!"
elif $ (id $ name &> / dev / null); then
echo "$ name already exist!"
elif $ (useradd $ name -d $ dir &> / dev / null); then
echo $ name is created !; echo 123456 | passwd --stdin $ name &> / dev / null; echo -e "Username is $ name \ nHome directory at $ dir \ nPassord is $ PW";
exit 10;
else
echo "Failed to add user!Please check whether the parameters you entered are correct!"
fi
done
Shell script writing and LINUX startup process, centOS password cracking
Shell script writing and LINUX startup process, centOS password cracking

2. Use expect to realize automatic login system.
#! / usr / bin / expect
set user root
set PASSWD 123456
set IP 192.168.43.106
set timeout 10
spawn ssh $ user @ $ IP
expect {
"yes / no" {send "yes \ n"; exp_continue}
"password" { send "$ PASSWD \ n"}
}
interact
Shell script writing and LINUX startup process, centOS password cracking

3. Briefly describe the startup process of the Linux operating system

1. Load the hardware information of the BIOS and obtain the first boot device
2. Read the boot information of the boot loader (grub) of the first boot device MBR
3. Load the core information of the core operating system, the core starts to decompress, and Try to drive all hardware devices
4. The core executes the init program (centos7 is systemd), and obtains the default running information;
5. The init program executes the /etc/rc.d/rc.sysinit file
6. Starts the core plug-in module
7. Init executes various batch files (scripts)
8. Init executes /etc/rc.d/rc.local
9. Executes / bin / login program, waiting for user to log in
10. After logging in, starts to control the host with Shell

4. Crack the centos7 password.
1. First, press "E" on this interface during startup
Shell script writing and LINUX startup process, centOS password cracking
2. After entering, under the arrow keys, find "LANG = ZH-CN.UTF-8", enter "rd.break" after this command, after completion Press ctrl + X to enter
Shell script writing and LINUX startup process, centOS password cracking
3. Enter this command and enter the following command
Shell script writing and LINUX startup process, centOS password cracking
4. After restarting, do not press anything, there will be a percentage of reading, waiting for completion.
5. Enter the user name root and password. The crack is complete.

Guess you like

Origin blog.51cto.com/14671983/2488052