1. Single-user mode:
Single-user mode in Linux can be used to compare the security mode in Windows. The most common feature in single-user mode is to modify the root password. How to enter single-user mode:
Restart linux,3 seconds and press ENTER to enter the new screen. If grub is encrypted, you need to press the P key first to enter the grub password. Then press the E key, select the second line, and then press the E key, at the end of the content with 1 or a single or S, enter and press B to start, you can enter the one-user mode.
[Email protected] ~]# passwd
Make changes and reboot. Here's how to Encrypt grub:
[Email protected] ~]# Grub-crypt--MD5
password:111111
Retype password:111111
$1$sqokzg6f$cej0v. vrvf6m3cajade8g/
Copy the encrypted password and modify the following file:
[[email protected] ~]# vim/etc/grub.conf//or vim/boot/grub/grub.conf soft link relationship
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5B/6C/wKioL1UJETeSKcdWAADzLzkuPP8465.jpg "title=" 9h9w2cr10l{o{} (]1_2 (bbt.jpg "alt=" Wkiol1ujeteskcdwaadzlzkupp8465.jpg "/>
Figure -1/boot/grub/grub.conf File
As shown in 1, add a row between the Hiddenmenu and the title line, password=111111 can specify a clear text password, password--encrypted paste the generated MD5 password and specify a non-plaintext password. Grub can also be used in two forms of encryption:
[Email protected] ~]# Grub-crypt--sha-256
[[email protected] ~]# grub-crypt--sha-512//default form, equivalent to Grub-crypt
method, paste the generated password into the/boot/grub/grub.conf file.
2. Rescue mode:
Rescue mode can be analogous to Windows PE, when the system does not start properly when the data can be extracted through rescue mode or repaired. How to enter rescue mode:
Restart Linux, press F2 during restart, enter BIOS settings, adjust boot boot order, boot from CD-ROM drive (disc boot), and then press F10 to save and restart. Select the third row Rescue installed system to enter rescue mode. The period will let you choose the language, keyboard type, whether to turn on the network card, read-only access or read and write access (recommended to choose Continue, that is, read-write form). The original Linux system will then be mounted under/mnt/sysimage. After display 2 interface: 650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/72/wKiom1UJFG2QQRCFAACZE0y5v9s089.jpg "title = "3{1c88_c{13{n]0u8v6y%ic.jpg" alt= "Wkiom1ujfg2qqrcfaacze0y5v9s089.jpg"/>
Figure-2 Rescue Mode entry Form
The first action goes directly into the shell, the second line goes into diagnostic mode (temporarily unaware of what the entry does), and the third line restarts. Select first line, enter after
Chroot/mnt/sysimage
command to enter the original Linux system file system, can be modified. cannot be restarted directly after completion, returned via logout or Ctrl + D, and then restarted via reboot or Shutdown-r now or init 6 command.
3. System operating Level:
There are 7 operating levels of Linux systems:
0-Turn off the machine
1-Single User
2-Multi-user mode with no NETWORK service
3-Standard multi-user mode//Shell
4-Retention level
5-graphical interface
6-Restart
The operating level entered by default at system boot is modified in the following file:
[Email protected] ~]# Vim/etc/inittab
Id:3:initdefault:
You can change the number after the ID. Remember not to set the 0 and 62 levels as the default, or the system will not start normally, you need to enter the single-user mode to change the RunLevel back. Typically we use the standard multi-user mode as the RunLevel.
Use the following command to view the previous and current operating levels of the system:
[Email protected] ~]# RunLevel
N 3//Last unknown, this run level is 3
4.Linux start-up process:
Understanding the Linux startup process helps us to quickly find and locate the cause of the problem when the system fails to start. Let's start with a starting flowchart, 3:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5B/6D/wKioL1UJHMHjDA4yAAfDLBDFh4M965.jpg "title=" Boot.jpg "alt=" Wkiol1ujhmhjda4yaafdlbdfh4m965.jpg "/>
Figure-3 Linux boot process
This picture has been said to be very clear, in words to describe:
(1) System power-up
(2) Initializing hardware (video card, memory, hard disk, time, etc.)
(3) Look for boot media (CD-ROM, HDD, USB, PXE, etc.)
(4) MBR (master boot record, including three parts: Boot program, boot loader, 446 bytes; partition information, 64 bytes, checksum code, 2 bytes (this two bytes is a-AA, for all MBR is the same, understand). Total 512 bytes). To view MBR content:
[[email protected] ~]# Touch MBR
[[email protected] ~]# dd IF=/DEV/SDA of=./mbr Bs=1 count=512
[Email protected] ~]# hexdump-c./mbr
can be viewed. Note that the MBR is 16 binary and cannot be viewed by the cat, head, tail, and other commands.
Boot Loader is divided into grub and Lilo, and now basically no longer using Lilo
(5) Enter the/boot/grub/directory, the most important of which is the three types of files Stage1, stage1_5 and Stage2, where Stage2 is the grub core image.
(6)/boot/grub/grub.conf start kernel with this file
(7)/sbin/init
(8)/etc/inittab decide which system operation level to use
(9)/etc/rc.sysinit or/etc/rc.d/rc.sysinit start the network, detect SELinux, set the system time, switch on the switching zone.
/etc/rc.d/rc0.d//etc/rc.d/rc1.d//etc/rc.d/rc2.d/.../etc/rc.d/rc6.d/enter the appropriate folder based on the runlevel used to open the appropriate process for different runlevel, Close the process (viewed through ll/etc/rc.d/rc3.d/, where K begins with the process to be closed, S begins with the process to be opened, the number represents the priority, and the smaller the number, the higher the priority).
(one)/etc/rc.local or/etc/rc.d/rc.local, the first file that is run after the system starts, allows the user to personalize the configuration, such as mounting the hard disk, or booting the Nginx service.
(/bin/login) To enter the login status.
5. Files used when the user logs in:
(1) Global file: A file that will be loaded regardless of which user is logged on
[Email protected] ~]# Vim/etc/profile
[Email protected] ~]# VIM/ETC/BASHRC
For example, modify/ETC/BASHRC and add a line to the bottom of it: Alias cls= ' Clear ', which adds the alias for all users to the clear command.
(2) Non-global files: Files that are loaded separately for each different logged-on user
[Email protected] ~]# vim ~/.bash_profile
[Email protected] ~]# vim ~/.BASHRC
For example, to modify/ROOT/.BASHRC, add a line to the bottom of it: stty-echoctl, you can hide the ^c tag that appears when you use Ctrl + C for the root user.
Note:profile,. Bash_profile is executed once for the first time the user logs on, BASHRC,. BASHRC is executed once when a shell is opened. In the former, environment variables are usually configured, and aliases are typically configured in the latter.
If the. Bash_profile and. BASHRC in the user's home directory are deleted, the login will be abnormal and the workaround:
[[email protected] ~]# cp-p/etc/skel/.bash*/root//-p parameters, copying users, user groups, and permissions
Can. (Requires single-user mode or rescue mode)
Learning Notes (ii)--Single user mode, rescue mode, RunLevel, startup process, login file