1.13 Single-user mode
If you forget your Linux password, you can change the password in single-user mode. The premise is that we need to know the grub password (or grub has no password) and if you don't know the grub password then use rescue mode to change the password. 1.13.1 Reboot your virtual machine (reboot, init 6, Shutdown-r Now these commands are commands to restart the system. Init 0, Poweroff These are the system shutdown commands. )
Right click = "SELECT power =" Restart client
When you see this interface, press the up and down keys of the keyboard to select the first item. You can see the options at 2 and then press the "E" key on the keyboard.
Enter Grub, press the DOWN ARROW key to find the linux16 option and then position the cursor to RO (read-only) and change the RO to RW (read-write), followed by init=/sysroot/bin/sh (meaning that you load the command line so that you can change the password), and then press the keyboard CTRL +x
At this point you are in the directory you are in your original system root directory. We've configured the/root/.ssh/authroized_keys file before.
We can use Cta/sysroot/root/.ssh/authroized_keys to view
1.13.2 How to switch to the directory under the previous root user that we can use chroot/sysroot/ run again Cta/root/.ssh/authroized_keys we can see we've entered the
1.13.3. change user password passwd root
A small box appears stating that the virtual machine does not support Chinese, we need to define it as English run lang=en: the definition language is English (CTRL + C can terminate the current command)
1.13.4 now we can log in with the new password, before we run a command touch/.autorelabel and then we can restart the client. Enter the system input user and new password.
This method is only suitable for operation on Linux native computer. 1.14 Rescue Mode There are 7 running levels, from 0 to 6, and we just said that the single user is 1.
1.14.1 use rescue mode to change the password (first shutdown, to the virtual machine edit = "Select Cd/dvd=" select Start-up connection) and then your image file path to choose the right
Start the CD-ROM drive, which is the first startup object
Select Boot
Use the keyboard plus minus sign to put the CD-ROM to the first item,
Press the F10 of the keyboard to save, enter
Enter
Enter
in the carriage return , it means entering the root user directory below to enter this command
1.14.2 then enter the passwd root command to change the password
1.14.3 give your optical drive power off, set the method
1.14.4 then the computer right-click = "Power =" Restart the client, use your new password to log in to the root user the benefit of rescue mode is that when you change the computer configuration file is wrong to cause your computer will not be able to drive, you can use this method to change the wrong file in the right.
1.15 Cloning a virtual machine
1.15.1 Put your virtual machine
Linked clones use less space and do not need to be fully cloned
You can make a name and choose where to store it.
1.15.2 Modify the IP address of your cloned machine, or it will be in conflict with your other machine when it starts up . Enter the NIC configuration file
Edit OK Press ESC to exit, and then press (: WQ) Enter
Restart the network server
1.15.3 Modify the name of the host This is the configuration file that changes the host name directly, you can restart the host to see the changed host name.
1.15.4 cloning machine using the Xshell key can also log in, because the key is the same, you need to change the password on the line.
1.16linux machine log in with each other
1.16.1 using Xshell to open our two Linux machines
We make the "w" Command View momoco-02 has several terminals
We then use momoco-01 to connect the momoco-02
note that 1 and 2, after you enter 1 return to the car, enter the momoco-02 password can log in momoco-02
Go back to momoco-02 and see how many terminals
Here is the momoco-01 login momoco-02 information, ctrl+d "can exit the current user"
1.16.2 standard notation for remote connection commands
[Email protected] ~]# ssh-p [email protected]-p number "Remote connection specified port" default to 22 port if not entered [email protected] "username user name IP IP Address "If the user name is not entered, the default is the root user
1.16.32 machines using keys to log in to each other our Linux also has a key function
enter [[email protected] ~]# ssh-keygen1. 2 Set password do not want the password to enter directly. 3-place return. 4 is the path to the private key. 5 is the path to the public key
We're pasting the public key into Momoco-01 's/root/.ssh/authorized_keys.
The same method can be set momoco-02, so that the root password can not be logged into each other
1.16.4 Close SELinux
[[email protected] ~]# Getenforce "See if SELinux is off" show this is not off
use [[email protected] ~]# Setenforce 0 to temporarily close
1
Linux forgot root password How to change password and multiple Linux mutual use key connection