Ubuntu, Debian, Kali, CentOS等linux重置root密码
来源:互联网 发布:淘宝怎么改会员名字 编辑:程序博客网 时间:2024/05/22 17:48
Forgetting
password is an hassle. We try to be vigilant with our security and set a complex password. We also try not to login using directly into root account (in most production boxes) and use instead. So it’s not very unlikely to loose your root password and depending on how you’ve setup your access, you just might not be able to reset it using . Following post shows you two different ways to reset root password in Ubuntu, Debian, Kali, CentOS or pretty much any Linux distributions.Option 1: Reset root password from Grub
Step 1.1: Boot in to GRUB menu
Boot to the
menu. Then, press (for edit) before Linux has a chance to boot. (Most standard installation will allow you 5 seconds to choose and Boot option is Grub, so you’ve got plenty of time)Step 1.2: Edit GRUB menu
Using your keyboard arrow keys, move the cursor down a line or so, and press
(for edit) again, you should now be on the kernel line, and press to go out to the very end of that line. Now hit the space-bar once, if necessary, to add a space, and then add one of the following:Then press
, and you’re back at the kernel line, press (for boot) and the computer will proceed to boot to a root prompt.Step 1.3: Remount filesystem as Read/Write to save changes
At this point, the root file system is still mounted read-only, so enter the following command:
Step 1.4: Reset root password / Change password
Then type:
Enter your new password. Retype if asked to confirm. Change your pw with a
command. If you’re not sure, should help.Step 1.5: Reboot and off you go
Then restart the machine by typing:
Now you should be able to login with your new root password as required.
Option 2: Reset root password using a Live CD/DVD or Live USB
Using a Live Linux CD/DVD or Live USB is another option to reset root password if you’ve uncomfortable using Grub menu.
Following is what you do:
Step 2.1: Boot Computer using any Live Linux CD/DVD or USB
Start up the computer with a Linux live CD (or USB key). You can use any Linux distro such as Debian, Ubuntu or even Kali.
Step 2.2: Mount Filesystem
Using the Disk Utilities available from your device, mount the partition that hosts your
folder (probably marked as bootable).Ideally following command does the trick
Where
or similar is the partition that contains folder.Step 2.3: Identify correct shadow file in correct /etc folder
In a command line, go to
under your mounted partition, probably in and contains a long hd id-like number. Notice the dot before ; don’t go to . You can check that you’re in the right folder with command. If you get anything, you’re in the right folder and you can proceed to Step 4.Step 2.4: Make a backup of the shadow file
Just to be safe, make a backup copy of your
file. I used command.Step 2.5: Open shadow file using any text editor
Using your favorite text editor (vi, nano or pico), edit your
fileStep 2.6: Locate the root line
Locate the root line. It’ll look something like
(You’ll have a some random numbers is there)Step 2.7: Replace encrypted password line
Replace the [encrypted
] part of the line with a single exclamation mark without double quotations. That tells Linux to authorize the mentioned user to access the system with no pw, so be cautious Your line will then look something likeStep 2.8: Save changes
Save your changes and exit the command line
Step 2.9: Unmount the partition
Back to your Disk Utilities program, unmount the partition you mounted in step 2 above.
Where
or similar is the partition that contains folder.Step 2.10: Poweroff and remove boot media
Poweroff your computer and remove all media, may it be USB key, CD, or whatever.
Step 2.11: Restart and boot into rescue mode
Now start/restart your computer and, in the grub menu, choose
. You’ll find yourself in a command line of a root session with no .Step 2.12: Reset root password / Change password
Change your password with a
command. If you’re not sure, should help. Once done, you can restart again and now you should be able to login as user from terminal (maybe not from SSH depending on how you’ve configured your SSH server). So there you go, two options to reset root password in Ubuntu, Debian, Kali, CentOS or pretty much any Linux distributions.- Ubuntu, Debian, Kali, CentOS等linux重置root密码
- debian、ubuntu、kali忘记root密码问题
- debian8设置root密码 重置root密码(debian centos)
- debian重置root密码
- CentOS root 密码重置
- centos重置root密码
- CentOS重置root密码
- linux/ubuntu 下重置mysql root 密码
- ubuntu 重置root密码
- ubuntu root密码重置
- ubuntu重置root密码
- ubuntu 重置 root 密码
- Ubuntu重置root 密码
- ubuntu重置root密码
- Ubuntu 重置root密码
- Linux重置root密码
- Linux Root密码重置
- centos 重置root密码方法
- Spark性能优化第六季
- poj 2385
- 06,缓冲区
- MySQL触发器
- CentOS服务器安全设置
- Ubuntu, Debian, Kali, CentOS等linux重置root密码
- Android异步消息处理机制详解
- AIM Tech Round 3 (Div. 2) ABCDE题解
- 不使用算数运算符 完成两数求和
- COM组件开发(一)—— 对象与接口 .
- CSS中position定位
- maven创建web工程第一次使用jetty运行报错
- 07,数组
- 月薪3万的程序员都避开了哪些坑?