You must have encountered these situations in CentOS

"

Passion is energy. Feel the power that comes from focusing what excites you.

—— Oprah Winfrey

"

CentOS virtual machine has not been used for a long time, what should I do if I forget the password? How can it be reconciled to delete it and start again? If I want to install a certain command, can I just use yum install? What should I do if the remote connection server reports an error?

1. Change password when CentOS cannot log in##

**Background: **The virtual machine forgets the root password and I don't know how to log in

**Environment: **CentOS, root account

operating:

  1. Turn on the virtual machine, select the item page before entering the system, and press the e key to enter the system configuration file

  2. Move the cursor down and find a sentence at the beginning of Linux16, which probably means the following:

Linux16 /vmlinuz-3.10.0xxxxxx.x86_64 root=UUID=xxxxxxxx ro  crashkernel=auto rhgb quiet LANG=zh_CN.UTF-8
  1. Add a space at the end of the line and enter init=/bin/sh

  2. Next press Ctrl + x key combination to enter single user mode

After waiting for a while, you will find that you have entered the system, but the command line prefix becomes similar to the effect of sh-4.2#

  1. Enter the following command:
mount -o remount,rw /
  1. Then enter the following command:
passwd
  1. The next step is to modify the root account password

Repeat to enter a password with no less than 8 digits (the password is not displayed when you enter it, just enter it correctly and press Enter)

  1. The word successfully appears to indicate that the modification is successful, but it needs to continue to take effect

  2. Enter the following command:

touch /.autorelabel
  1. After the operation is complete, there is one more step:
exec /sbin/init

The next step is to wait for the system to restart (it may take a few minutes, you need to wait patiently, do not shut down halfway)

2. Installation command tips##

Installation commands, everyone will think of:

yum install xxx

But not all commands are true. Some are in a certain toolkit and need to download its basic environment. How to do it?

Just execute:

yum search xxx

Wait patiently for a few minutes until the execution is complete. Then install the last prompt module.

Example

yum search killall

prompt:

Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile

base: mirrors.163.com
extras: mirrors.aliyun.com
*> updates: mirrors.aliyun.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Matched:killall-----------------------------------/
psmisc.x86_64 : Utilities for managing processes on your system

You can see that the killall command is in psmisc.x86_64

Then enter:

yum install psmisc.x86_64

3. Remote connection server##

**Background: **Use ssh to connect to the server for related operations and report errors

**Environment: **local MacOS, server CentOS

operating:

  1. Use the command to connect remotely, and then report the error as follows:
❱ ssh [email protected]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now(man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:ZBm9L5432tibaN5+weK4h9NJzqrc76lvxOUkVvSLGac.
Please contact your system administrator.
Add correct host key in/Users/ethanyan/.ssh/known_hosts to get rid ofthis message.
Offending ECDSA key in/Users/ethanyan/.ssh/known_hosts:6
ECDSA host key for192.168.xx.xx has changed and you have requested strict checking.
Host key verification failed.
  1. Use the following command to solve:
ssh-keygen -R IP address you want to visit
  1. Finally, use the command again to connect and find that the connection is successful:
ssh user@The ip address you want to visit

Recommended Posts

You must have encountered these situations in CentOS