Change the root password in centos single-user mode

Source: Internet
Author: User

Change the root password in centos single-user mode [reprint]

Reprinted from: centos single-user mode: modifying the root password and grub Encryption

When the Linux system is in normal state, after the server host is started (or restarted), the system pilot program can automatically boot the Linux system to multi-user mode and provide normal network services. If the system administrator needs to perform system maintenance or a startup exception occurs, the system needs to be managed in single-user or repair mode. One premise of using the single-user mode is that your system Boot Tool (grub) works normally. Otherwise, you must use the repair mode for system maintenance. Note: In single-user mode, network service is not enabled and remote connection is not supported.

In a Linux system, different run levels indicate different running states of the system. For example, if a Linux server is running normally at the run level 3, it is a multi-user mode that can provide network services; the running level 1 only allows administrators to operate on the server host through a single console, that is, "single user mode ".

Take centos as an example:

Enter Single User Mode

The premise of entering the single-user mode is that the system boot loader works properly. The following uses GRUB as an example to describe the access method. There are three operation buttons "A", "E", and "C" in the grub boot menu. You can use these buttons to enter the single-user mode.

Method 1 use the "A" button to enter single-user mode ------ recommended: simple operation

This is the fastest way to enter the single-user mode. Use the "A" operation button in the grub Startup menu to edit the Kernel Parameter and enter single at the end of the line to inform the Linux kernel that the subsequent startup process needs to enter the single user mode. Press enter.

 

Method 2: Use the "e" button to enter the single-user mode

Use the "e" operation button in the grub Startup menu to go to The centos Startup menu and move the cursor to the "kernel" configuration item line ,.

 

Position the cursor to the kernel menu item

Press the "e" key to edit the "kernel" menu item, and enter single at the end of the line to inform the Linux kernel that the subsequent startup process needs to enter the single-user mode.

Set kernel/vmlinuz-2.6.18-53.el5 Ro root =/dev/volgroup00/logvolroot

Change to kernel/vmlinuz-2.6.18-53.el5 Ro root =/dev/volgroup00/logvolroot single

After the modification, press enter to return to the centos Startup menu item interface.

 

Finally, press the "B" key and use the changed centos boot menu item to start the single-user mode.

Method 3: use the "C" button to enter the single-user mode

This is the most troublesome way to enter the single-user mode. Generally, this method is not used to enter the single-user mode. This is intended to familiarize yourself with grub command line interface operations. Use the "C" operation button in the grub Startup menu to go To the grub command line interface. Use the root, kernel (single input at the end of the line), and initrd commands under grub to specify the startup parameters, respectively, and then use the boot command to start to single-user mode.

 

Go to single-user mode from the grub command line interface

---------------------------------------------------------------------

After entering the single-user mode

When the system enters the single-user mode, you do not need to enter the user name and password. After the system is started, the administrator root permission is directly obtained. The console prompt is "#".

 

Console interface in Single User Mode

The preceding startup information is critical:

Remounting root filesystem in read-write mode: [OK]

Indicates that the root file system in single-user mode is readable and writable. Only the root file system can be read and written can the system administrator maintain the system. If the system configuration and script file are incorrect, the root file system in single-user mode enters the read-only file system read-only status, run the following command to re-mount the root file system in read/write mode:

Sh-3.1 # Mount-O remount RW-T ext3/

When the Linux system enters the single-user mode, no one else (through the network) will interfere with the running status of the system because it has stopped any network service and network configuration (the network interface is invalid, administrators can safely perform system-level maintenance on the Linux system. In single-user mode, Linux is a fully functional operating system except for its network functions. In single-user mode, you can perform the following maintenance and management tasks:

Reset the superuser password

Maintain System partitions, LVM, and file systems.

Back up and restore the system

A typical application of single-user mode is the "password setting" of the root user ". For some Linux systems (such as student labs) that are temporarily used or used for lab purposes, users are often changed, while the root user's password may be lost, in this case, you can change the password of the root user in single-user mode.

Sh-3.1 # passwd

Changing password for user root.

New UNIX password:

Retype new Unix Password:

Passwd: All authentication tokens updated successfully.

After the system enters the single-user mode, run the passwd command at the "#" prompt to update the password of the root user, after the system restarts, you can use the updated password to log on to the system as the root user.

 

Related Article

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.