Linux server forgot user name password to find ways to sum up

Source: Internet
Author: User

Problems encountered today, the server version is ubuntu9.04 I went insane to change the user uid in the/etc/passwd file

After a change, Sudo went wrong:

Sudo:uid 1000 does not exist in the passwd file!
Who are?

As a result nothing can be done, and no other user has sudo permission. Tried the PHP Trojan, looked for this system version of the bug download Full-nelson.c and compiled to bring the right to root did not succeed.

Action steps are as follows:

1. Press the power key to turn off the machine, wait for the normal shutdown and reboot.
2. Press ESC when you turn on the boot menu and move to the second item "Ubuntu 9.04, Kernel 2.6.28-11 server (Recovery mode)" carriage return.
3. In recovery menu, select the last "root Drop to root shell prompt" and then return.
4. Executive Order

The code is as follows Copy Code

Mount-o REMOUNT,RW/
Sed-i "S#1876#1000#g"/etc/passwd

(This command is to change the UID back, if you want to change the password here is the command passwd your username and then enter a new password, if you do not even remember your own user name, you can ls/home see)
5. Finally press Ctrl+alt+del three keys to restart the server.

I encountered an error while operating to step 3rd

Give root password for maintenance (or type control-d to continue)

The solution is to press E key in the 2nd step to enter the editing mode, select kernel line again press e key, the RO single replace with RW single Init=/bin/bash after carriage return confirmation, press b key boot boot. This will not report give root password for maintenance error.

The machine is guided by Lilo, so change

The code is as follows Copy Code

Boot:linux Init=/bin/bash


Workaround Two


With Grub system Boot Manager, single user login method;

After Grub starts, move the keyboard to the Linux startup entry, press E, and then move the keyboard to a line similar to the one below, which is the kernel line:

The code is as follows Copy Code
KERNEL/BOOT/VMLINUZ-2.6.11-1.1369_FC4 ro root=label=/1 rhgb quiet

Move the cursor over this line, click E again, enter the edit line, a space at the end of a line, and then enter Linux single, which is similar to the following:

The code is as follows Copy Code
KERNEL/BOOT/VMLINUZ-2.6.11-1.1369_FC4 ro root=label=/1 rhgb quiet Linux single

End edit, press ENTER to return;

Then we have to start the system, click the B key to start;

When entering the Single-user mode, the system prompts us to enter the root password, enter the system after the correct input, you can use Df-h to view the file system mount location, etc., you can also use Fdisk-l to view the partition, but the file system write operation, may also want to see the following;

After a single user enters the system, the system may be read-only, and the following command is to be run;

The code is as follows Copy Code

#mount-O REMOUNT,RW/


Workaround three

Lilo Guide

1. In the presence of Lilo: prompt, type Linux single

The code is as follows Copy Code

Boot:linux Single

2. Enter directly into the Linux single user mode 3. vi/etc/passwd

Delete the password in the root entry

(You can also reset the root password directly using the passwd command)

4. Reboot reboot, root password is empty


Finally summed up the use of root users to do the most of the backup user, the same permissions as root, so that the password can be set to save, the following introduction of Linux Create user brief introduction

Create users under Linux
1. Add FTP User

The code is as follows Copy Code
Useradd ftpname-d/home/ftp
passwd ftppwd

The following actions are performed with root permissions:
Service vsftpd start starts Linux with its own FTP service
2. Add Ordinary Users

The code is as follows Copy Code
Useradd Nagios–d/usr/local/nagios
Chown Nagios.nagios/usr/local/nagios

To switch users to Nagios users, add Nagios Access users:

The code is as follows Copy Code
Su Nagios
Htpasswd–c/usr/local/nagios/etc/htpasswd.users Nagiosadmin

The system prompts for a password two times, such as two input nagios.
Note: This is the first time you create a user, you need the "-C" option to create a file that holds your username and password, and you do not need the "-C" option when you add users or modify your password again.

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.