DEV Community

c3phas
c3phas

Posted on

Forgot my Root password

MEEEEEEEEEN WHAT WAS THE ROOT PASSWORD

Today we are going to play around with our Linux box

NOTE:This article can be used for malicious activity
I hereby take no responsibility for how you will utilize
the following

Forgot your Linux root password? well lets get around it

Run Levels in Linux
A run level in Linux is what determines what programs will run
or will be executed at system startup
This is what determines whether your system loads a GUI or the
CLI mode when booting

There are 7 run levels staring from 0-6
Each runlevel has some services started or stopped and this is normally what determines the default behavior of the machine
I will not get into much details concerning this levels, if you want a more detailed explanation leave a comment.
The runlevels are
runlevel 0 - system halt
runlevel 1 - single mode
runlevel 2 - multiple user mode without network file system
runlevel 3 - multiple user mode under CLI mode
runlevel 4 - This is left blank thus it can defined by the user
runlevel 5 - multiple user mode under graphical user interface(default on most desktops
runlevel 6 - reboot

The two used modes by default are the runlevel 3 and the runlevel 5
if you want to find out which runlevel you are on ,on the terminal type
$runlevel
The scripts driving this levels are located in the /etc directory

THE MEAT OF THIS ARTICLE
our primary focus is the runlevel 1(single user mode)
This can be compared to what the folks at windows call safe mode
in this mode networking services will not be started but it allows one to make changes to the system

NOTE:This will only work if the systems' grub menu is not password protected

lets do this folks:
step 1: Reboot your machine and on the grub menu hit 'e' to enter the edit mode.
step 2: Find the line that starts with Linux and scroll to the end of that line
step 3: Delete the characters all the way to 'ro'
-The ro stands for read only ,change this to 'rw' to allow writing
-After replacing ro with rw hit space and add init=/bin/bash
your line looks like this
rw init=/bin/bash
step 4: Hit Ctrl-x or f10 to boot with current settings

The boot now gives you a shell with root privileges and you can go ahead and change the root password the usual way.

$passwd root

After confirming the password, reboot and there we have it , a new root password.

Top comments (0)