CertCities.com -- The Ultimate Site for Certified IT Professionals
Keep on Top of the Latest Certification News: Subscribe to CertCities.com Newsletter Share share | bookmark | e-mail
  Microsoft®
  Cisco®
  Security
  Oracle®
  A+/Network+"
  Linux/Unix
  More Certs
  Newsletters
  Salary Surveys
  Forums
  News
  Exam Reviews
  Tips
  Columns
  Features
  PopQuiz
  RSS Feeds
  Press Releases
  Contributors
  About Us
  Search
 

Advanced Search
  Free Newsletter
  Sign-up for the #1 Weekly IT
Certification News
and Advice.
Subscribe to CertCities.com Free Weekly E-mail Newsletter
CertCities.com

See What's New on
Redmondmag.com!

Cover Story: IE8: Behind the 8 Ball

Tech-Ed: Let's (Third) Party!

A Secure Leap into the Cloud

Windows Mobile's New Moves

SQL Speed Secrets


CertCities.com
Let us know what you
think! E-mail us at:



 
 
...Home ... Editorial ... Columns ..Column Story Friday: April 4, 2014


 Inside the Kernel  
Emmett Dulaney
Emmett Dulaney


 Changing the Root Password
The unthinkable has happened: You can't obtain root access on one of your Linux servers! Keep calm, because this problem can be solved fairly easily by following a few steps.
by Emmett Dulaney  
12/15/2009 -- Imagine the unthinkable has happened: You can't obtain root access on one of your Linux servers!

You scratch your head and wonder whether it was changed by the junior administrator on the day you fired him, if it's a value you mistyped (twice) when last changing it, or if there's simply some sort of corruption keeping it from successfully logging in.

Regardless of the cause, this is a situation that must be rectified immediately; it's necessary to know the root password to perform many system administration tasks.

But keep calm. While your worry is justified, the problem can be solved fairly easily by rebooting the PC and resetting the root password by following these steps:

1. Reboot the PC (select Reboot as you log out of the GUI screen) or power up as usual. Soon, you'll see the graphical GRUB boot loader screen that shows the names of the operating systems you can boot. If your system runs the LILO boot loader, press Ctrl+X and at the boot prompt, type "linux single" and press Enter. Then proceed to Step 4.

2.  If you have more than one operating system installed, use the arrow key to select Linux as your operating system. Then press the A key. GRUB prompts you for commands to add to its default boot command.

3. Press the spacebar, type the following, and press Enter:

single
Linux starts up as usual but runs in a single-user mode that doesn't require you to log in. After Linux starts, you'll see a command-line prompt that ends with a hash mark (#), similar to this:
sh-3.00#

4. Type the passwd command to change the root password as follows:

sh-3.00# passwd
Changing password for user root.
New password:

5. Type the new root password that you want to use (it doesn't appear on-screen) and then press Enter. Linux asks for the password again, like this:

Retype new password:

6. Type the password again and press Enter. If you enter the same password both times, the passwd command changes the root password.

7. Now type "reboot" to reboot the PC.

After Linux starts, it displays the familiar log-in screen. Now you can log in as root with the new password.

NOTE: If you're running SUSE Linux, then at Step 3, type "single init=/bin/sh" (instead of "single") and, before proceeding to Step 4, type "mount / -n -0 remount,rw." After that, perform steps 4 through 6 to change the root password. After changing the password, type "mount / -n -o remount,ro." Then continue to Step 7 and reboot the PC.

As an aside, make sure that your Linux PC is physicallysecure. As these steps show, anyone who can physically access your Linux PC can simply reboot, set a new root password and do whatever he or she wants with the system.

Another way to protect against resetting the password is to set a GRUB password, which causes GRUB to require a valid password before it boots Linux (of course, you must then remember to enter the GRUB password every time you boot your system).

A great How-to on setting a GRUB password can be found on the Ubuntu site here.


Emmett Dulaney is the author of several books on Linux, Unix and certification. He can be reached at .

 


More articles by Emmett Dulaney:

-- advertisement --


Current CertCities.com user Comments for “Changing the Root Password

There are no comments yet. Post one now.

Your comment about: “Changing the Root Password”
Name: (optional)
Location: (optional)
E-mail Address: (optional)
Comment:
   

-- advertisement (story continued below) --

top