If you forget the root password, what to do, today recommended two simple methods, suitable for just start Linux people.
Log in to the system in single maintenance mode and use the Grub boot Manager to change the password (if your boot Manager is grub).
Restart the system, press any key while reading the second, the screen will appear a menu screen, carefully read the instructions below the menu, press e to enter the grub editing mode, the screen is displayed roughly as follows:
Root(hd0,0)
Kernel/vmlinuz-2.6.18-128.el5 ro ROOT=LABEL=/RHGB Quiet
Initrd/initrd-2.2.18-128.el5.img
At this point, move the cursor to the kernel line, and then click e to enter the edit screen of the kernel line, and then in the screen that appears, the last party enters single:
Kernel/vmlinuz-2.6.18-128.el5 ro ROOT=LABEL=RHGB Quiet single
Press enter again to confirm, press b to boot into the single maintenance mode.
In single-player maintenance mode, you do not need to enter a password in tty1 to gain control of the terminal (root ), then you can change the password with the instruction passwd :
sh-2.05#
BASH#PASSWD Root
Re-enter password
Reboot
You can also edit the file that holds the root password directly
Vi/etc/shadow
Delete the root of the first row (that is, the line that starts with root): The contents of the post and the next:
Save the file
Reboot, the root password is empty.
This method applies to the Redhat version of the Linux system.
There is also a way to boot the system with the installation CD or RESCUECD, the Linux rescue status, mount the Original/partition:
Cd/mnt
mkdir HD
Mount-t Auto/dev/hdax ( partition number where the original / partition is located )HD
CD HD
Chroot./
passwd Root
You may have noticed that the above method also illustrates the Linux single-user mode security vulnerability, if the ulterior motives want to change the root password, what to do. At this point, we can restrict single-user logons:
To configure the grub Password:
Modify the /boot/grub/grub.conf file (as you can literally see, this is the Grub configuration file)
or modify /etc/grub.conf(/etc/grub.conf is a symbolic link to /boot/grub/grub.conf ), as it does.
In fact, security is a system, set root password and grub password can not guarantee the absolute security of the system, any omission of a link may lead to system security problems, but set the password to a certain extent, improve the security level of the system.
This article is from the Linux Cloud Computing blog, so be sure to keep this source http://tyq727791620.blog.51cto.com/8324216/1635793
If you forget the root password of Linux