Click to See Complete Forum and Search --> : How to change a root password


linuxardo
12-16-2007, 10:27 AM
Consider the case on day i wake up from a bad dream ....which was all related to secret codes and in mornin when i start my pc and enter the root password .i messed up everything and could enter the right one....

all that is a story come to the point how can i change my root password.
one of my friend said that u can change it from grub but how??????
can anyone help./?????????

infiniphunk
12-16-2007, 01:19 PM
su passwd

not sure how to do it from GRUB tho.

saikee
12-16-2007, 01:20 PM
The Grub password is to protect the Grub menu from being altered and got nothing to do with Linux.

It is a sensitive area to teach others to change root password because it is a form of hacking if the one who raises the question is not the legitmate root user. If he/she is the legitimate root user then he/she can always change the root password using the command suggested by infiniphunk

linuxardo
12-16-2007, 02:06 PM
su passwd

i dont think that will work but i will try it....however it doesnt make nay sense........

infiniphunk
12-16-2007, 07:46 PM
Depending on the distro you're using, of course. If you're used to doing stuff with sudo instead, then it would be sudo passwd of course.

blackbelt_jones
12-16-2007, 11:04 PM
to change a root password, I thought it was

sudo passwd root

or as su:

passwd root

That's how I set a root password in Ubuntu.

infiniphunk
12-17-2007, 02:15 AM
I dunno it does it for me. Does it do the same thing with and without the 'root' argument on the end?

wheelnut
12-17-2007, 03:22 AM
Would it not be simpler to boot into single user mode (at the grub prompt) and when at the command line, then type:

passwd root

?

i845_
12-17-2007, 08:02 AM
When an argument is passed to su, without any options, su assumes it to be a username. For instance, if I wish to transfer the ownership of a session to a user named zook, I would issue the command:

su zook

Issue su without any arguments, and the operating system assumes that you want to change to a root session. Hence, it prompts you for the root password.

The commands, su passwd or su passwd root would probably fail, because su would assume passwd to be a username. One could use su -c passwd (su executes a command with superuser privileges, only when used alongwith the -c option), but then su would ask for the root password anyway, thereby defeating its purpose.

On the commands sudo passwd and sudo password root... well, on distros implementing sudo, you don't even need to know the root password. As long as you are a sudoer, and you remember your own password, everything will be just fine.

-------------------------

An extract from the Wikipedia entry on su:

"A related command called sudo executes a command as another user but observes a set of constraints about which users can execute which commands as which other users (generally in a configuration file named /etc/sudoers, best editable by the command visudo). Unlike su, sudo authenticates users against their own password rather than that of the target user (to allow the delegation of specific commands to specific users on specific hosts without sharing passwords among them and while mitigating the risk of any unattended terminals."

-------------------------

@linuxardo

Like saikee has rightly pointed out, the topic you have posted is a quite sensitive one, and so, I won't tell you exactly how to bypass the root password using Grub. Just a few pointers is all that you'll get:

a. Try booting Linux into single user mode or recovery mode, or b. try forcing the kernel to start the shell instead of init upon startup.

@saikee

I know this is a very sensitive topic. Please edit or delete my post as you deem fit.

Edit: Here (http://www.linfo.org/su.html)'s a manpage on su. Here (http://www.gratisoft.us/sudo/man/sudo.html)'s the sudo manual. The Wikipedia entries on su and sudo are here (http://en.wikipedia.org/wiki/Su_(Unix)) and here (http://en.wikipedia.org/wiki/Sudo) respectively.

mrrangerman43
12-17-2007, 08:15 AM
If you are logged in as root then to change the root passwd the only command you need to give is passwd and it will prompt you for your old passwd then to enter new passwd. If logged in as root you can change the passwd for any user by giving the command passwd /username/. If you are within your user account you can change the root passwd via sudo passwd root as blackbelt said in his post.

infiniphunk
12-17-2007, 08:22 AM
ok, but WHO'S password is it that is being changed by sudo passwd on ubuntu?? I always thought this was an easy way to bypass 'sudo' by assigning a password that I know to root.

i845_
12-17-2007, 08:35 AM
On Ubuntu, there exists a root account all right (/etc/passwd does list an entry for root), and it is the password of the root account that gets changed on issuing sudo passwd. And certain derivatives of Ubuntu (such as Linux Mint), even allow creation of a separate, tangible root account, just to make things more Fedora-esque.

However, like I said in my previous post, sudo authenticates users against their own password, rather than that of the root user. Hence, I see no reason to know or modify the root password on distros that implement sudo, as long the user knows his or her own password, and is a sudoer (i.e., he or she is authorized to use sudo for escalation of privileges...)

(Edit: It is due to the same reason, that one does not feel the persence of the root account on Ubuntu and other distros that implement sudo).

I always thought this was an easy way to bypass 'sudo' by assigning a password that I know to root.

Well, I don't know what you're exactly trying to mean by "bypassing". I mean, in Ubuntu, everytime you wish to execute an administrative command, you must prepend it with sudo, and supply your password to the system. Unless, of course, you do a sudo -s -H, which drops you to a root shell altogether... :confused: :confused: :confused:

bwkaz
12-17-2007, 07:34 PM
I dunno it does it for me. Does it do the same thing with and without the 'root' argument on the end? When passwd runs, it (obviously) needs to know which user's password is being changed.

The default user is the user that runs passwd. If passwd runs as root (its UID is zero), then it will change root's password by default.

If you give passwd a username on the command line, it will change that user's password instead, but only if you're root. (Actually it may be possible for one non-root user to change another non-root user's password, but if so, they'd have to know the other user's old password first. I've never tried it.)

So to answer your question, yes, it does do the same thing with and without the "root" on the end -- but only if you're running passwd as root.

(You can use passwd to change your normal user's password, too. I'm assuming you probably knew this, but just in case. :))

saikee
12-17-2007, 07:59 PM
I know there may be Ubuntu users out there after my blood but in a normal installation Ubuntu leaves out the root account and no root password is set.

If however an ordinary user tries
sudo passwdUbuntu will prompt for the changed roor password. Once entered the ordinary user can use this root password in exactly like any other Linux. This is to say by entering
su and then supplying the root password an ordinary user becomes a root user.

I run the root user like this in every version of Ubuntu and all its members of the family. Thus I use Ubuntu just like any Linux and forget about the sudo. I don't recommend it to others but I like one set of instructions applicable to every Linux and keep typing sudo is not my cup of tea as I am not in a security-critical situation.

By the way I don't use root account unless I am in need of doing a fair amount of system-related work.

linuxardo
12-22-2007, 07:08 PM
hey friends i got many ways to hack the root password..still experimenting
would be writing soon.......

karamba
01-01-2008, 10:11 PM
Here's how to change the root passwd from GRUB.

Start the PC and go to the GRUB menu.
* Press 'e' on the entry you wich to modify
* Press 'e' on the "kernel" entry
* Add init=/bin/bash to the end of the line
* Change "ro" for "rw"
* Press <Enter>
* Press 'b' to boot it

Once you're at the command line (as soon as the kernel loaded),
change directory to /etc/rcS.d (that's for a Ubuntu system, I saw /etc/init.d/rcS.d) and execute the scripts in order with "start" as argument. Personally, the only scripts I need are mountkernfs.sh, mountdevsubfs.sh, keyboard-setup and udev.sh

now you can type in "passwd root" without any questions :)