Linux reset root password and machine log in to each other

Source: Internet
Author: User
Tags safe mode

Single-User mode
  • System restart command: Reboot init 6 shutdown-r now
  • Shutdown command: Init 0 poweroff
  • Operating level: 0-6
      [[email protected] ~]# ls-l/usr/lib/systemd/system/runlevel*targetlrwxrwxrwx. 1 root root 15 May 28 18:4 8/usr/lib/systemd/system/runlevel0.target-Poweroff.target # # #关机lrwxrwxrwx. 1 root root 13 May 18:48/usr/lib/systemd/system/runlevel1.target-Rescue.target # # #单用户lrwxrwxrwx. 1 root root 17 May 18:48/usr/lib/systemd/system/runlevel2.target-Multi-user.target # # #多用户lrw Xrwxrwx. 1 root root 17 May 18:48/usr/lib/systemd/system/runlevel3.target-Multi-user.target # # #多用户 LR Wxrwxrwx. 1 root root 17 May 18:48/usr/lib/systemd/system/runlevel4.target-Multi-user.target # # #多用户 LR Wxrwxrwx. 1 root root 16 May 18:48/usr/lib/systemd/system/runlevel5.target-Graphical.target # # #图像界面lrwxrwxrwx . 1 root root 13 May 18:48/usr/lib/systemd/system/runlevel6.target-Reboot.target # # #重启  

  • Enter single-user mode to modify the root password: requires a grub password or is not encrypted
  • Restart the system, press the UP and down keys
  • Press E to enter grub to find the RO position modification
  • Change ro to RW init=/sysroot/bin/sh
  • Press CTRL + X to enter a command-line interface similar to safe mode
    Enter the following command to change the root password and restart directly.
    Rescue mode
  • Enter rescue mode to change the root password:
    Set up virtual machine mirroring

    Click on the virtual machine power supply, select Enter BIOS at startup, move CD-ROM drive to the first, F10 save to exit.

    Go to the Installation screen and select the third item

    Select the second item

    Enter into the carriage return and type 1

    Enter a command line mode after carriage return

    Enter the following command to modify the root password, restart the system, and do not forget to modify the boot system from the hard disk.
    Cloning a virtual machine

    Use a virtual machine to clone a virtual machine without a full clone.
    Configure the IP address of the clone machine
    Modify hostname: This command is a direct change to the configuration file/etc/hostname

    Linux Machine Mutual Login configuration if aminglinux-02 needs to log on aminglinux-01:
  • Operating on the aminglinux-02
    [[email protected] ~]# ssh-keygen        配置密钥Generating public/private rsa key pair.     Enter file in which to save the key (/root/.ssh/id_rsa):      指定目录Enter passphrase (empty for no passphrase):                  设置密码             Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.       私钥保存目录Your public key has been saved in /root/.ssh/id_rsa.pub.      公钥保存目录The key fingerprint is:79:cd:12:34:d1:54:c0:58:de:38:52:7e:eb:d4:61:6d [email protected]The key‘s randomart image is:+--[ RSA 2048]----+|          +B=o.  ||         ..=oo  .||          o = ooE||         . = o.+.||        S o o o .||         . . o   ||              .  ||                 ||                 |+-----------------+[[email protected] ~]# ls /root/.ssh/authorized_keys  id_rsa  id_rsa.pub  known_hosts
    • Copy the public key inside the id_rsa.pub into the/root/.ssh/authorized_keys inside the aminglinux-01.
    • Connection aminglinux-01

    • Firewall command
      [[email protected] ~]# getenforce           查看selinux状态Enforcing                                                     开启                                     [[email protected] ~]# setenforce 0        临时关闭[[email protected] ~]# getenforce                  Permissive                                                  关闭                     

Linux reset root password and machine log in to each other

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.