How to generate booting password after cancelling old one

Asked by suvala

I wish to install new cordless keyboard and for that system should start without password and for that I had canceled my password. But now for any change or any updating it asks for authentication and not accepting my old passwords. So what to do?
How can I restore my system? In menu system->Admini->..there is no restore location.What to do?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu shadow Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#1

If I understand you correctly, you want to set a new password for your Ubuntu user account, but you are being prevented from doing so because you have to enter your current password to do it, and you don't know your current password.

I am not sure what you mean when you say you "cancelled your password", but if you just mean you configured Ubuntu so you didn't need to enter your password to log in, that shouldn't have prevented you from using it to perform administrative tasks. In any case, however this problem arose, you should be able to solve it with the same techniques as you would use for resetting your password if you're unable to log in:

https://help.ubuntu.com/community/LostPassword

If those techniques don't work, then in your Ubuntu system, open a Terminal window (Applications > Accessories > Terminal) and enter this command exactly (you can copy and paste it)

mount | grep ' on / '

and press enter to run that command. You should see something like:

/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)

The part you're interested is the device name before "on" (in this example, it's /dev/sda1). Remember that, or write it down.

Now boot the computer from an Ubuntu Desktop Install CD and select Try Ubuntu. When the desktop comes up, run the Terminal and, in the Terminal window, run:

sudo mount /dev/sda1 /mnt

If the device name was different from /dev/sda1, put what you saw instead. Then run the commands:

sudo chroot /mnt
passwd suvala

If suvala isn't your username, put your username there instead. This will enable you to type in a new password. Enter your new password twice, as it requests. It's OK that no placeholders characters (like *) appear while you're entering your password.

Then run these three commands:

exit
sudo umount /mnt
exit

The last of those commands quits the Terminal window. Reboot the system by clicking the power icon on the upper-right corner of the screen and clicking Restart. Make sure to remove the CD before the system boots up again, so that you can get into your Ubuntu system on the hard disk. Now that you've reset your password, you should be able to authenticate when necessary.

Revision history for this message
suvala (suvala-msn) said :
#2

After failing lost password link's steps I tried your second suggestion and created password successfully but after removing CD & rebooting normally and trying to update or change booting mode it asks for authentication and after giving new password it fails.System is not accepting it.
suvala

Revision history for this message
suvala (suvala-msn) said :
#3

Can any body help me. I have window XP and Ubuntu on my desktop. If above problem remains, then I want to format (Remove) my Ubuntu drive without effecting XP. And then will add/install Ubuntu again. Is it possible? If yes then let me know the steps.

suvala

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#4

In that case, it seems that your problem may be with gksu or PolicyKit (which are used by many of Ubuntu's graphical programs to perform actions as root). If that is the case, then you should be able to perform administrative tasks (including updating the system) from the command-line using sudo. If this works, then that doesn't mean you problem is solved. However, in addition to giving useful diagnostic information and providing a workaround for your problem, updating your system from the command-line using sudo might also fix the problem, if the problem is due to a bug which is fixed by the update.

To update your system in this way, open a Terminal window (Applications > Accessories > Terminal) and run the command:

sudo apt-get update

If that command completes successfully, run the command:

sudo apt-get upgrade

If either of those commands are not successful (or you are not sure if they were successful), then please copy all the text from the Terminal and paste it here.

If they were successful, then reboot your computer and see if the problem is fixed.

Revision history for this message
suvala (suvala-msn) said :
#5

suvala@suvala-ubuntu:~$ sudo apt-get update
[sudo] password for suvala:
suvala is not in the sudoers file. This incident will be reported.
suvala@suvala-ubuntu:~$ sudo apt-get upgrade
[sudo] password for suvala:
suvala is not in the sudoers file. This incident will be reported.
suvala@suvala-ubuntu:~$ ^C
suvala@suvala-ubuntu:~$
_______________________________________________________________

Dear sir,
I had given password which was successfully done,but the above messages in terminal.
Please help.

suvala

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#6

It seems that, rather than this being a problem with gksu or PolicyKit, the problem is much simpler: Your user account doesn't appear to have administrator privileges. To test this hypothesis, please run the command "groups" (without the quotes) and paste the output here. This will also indicate if your user account is missing other important abilities; if so, we should be able to correct that and your lack of administrator privileges in one fell swoop.

Revision history for this message
suvala (suvala-msn) said :
#7

uvala@suvala-ubuntu:~$ groups
suvala adm dialout fax cdrom floppy tape dip video plugdev fuse lpadmin nopasswdlogin sambashare
suvala@suvala-ubuntu:~$

Revision history for this message
suvala (suvala-msn) said :
#8

suvala@suvala-ubuntu:~$ groups/
bash: groups/: No such file or directory
suvala@suvala-ubuntu:~$

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#9

The output of "groups" indicates that you are a member of most groups that an individually owned and managed computer's primary group should be in...with the conspicuous exception of "admin", which you are not a member of. The "admin" group, on an Ubuntu system, is the groups whose members have the ability to perform administrative tasks by running programs as "root" (the "superuser").

This is why entering your password when prompted for it doesn't enable you to perform administrative tasks, like updating the software installed on your system or modifying systemwide settings.

To add yourself to the "admin" group and solve your problem, you can follow the instructions at https://help.ubuntu.com/community/LostPassword, except, *instead* of step 3 (that is, instead of running the command "passwd <username>"), run the command

usermod -a -G admin <username>

replacing <username> with your username.

Since you were unable to get those instructions to work before, I realize that might not work this time. (If the reason you were unable to get those instructions to work before was that you were unable successfully get to step 3, then of course it won't work this time either.) Therefore, here are alternative instructions, which you will notice are similar to the instructions I gave above (for when https://help.ubuntu.com/community/LostPassword doesn't work for resetting your password).

(1) If you remember the device name of the partition that contains your Ubuntu system's root filesystem, feel free to skip to step 4.

(2) In your Ubuntu system, run this command in the Terminal: mount | grep ' on / '

(3) That command produces something like "/dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0)" as the output. The text before "on" (not include the space) is the device name of the partition that contains your Ubuntu system's root filesystem. Remember it (or write it down).

(4) Boot the computer from an Ubuntu Desktop Install CD and select Try Ubuntu.

(5) Open up a Terminal window.

(6) Run the command: sudo mount /dev/sda1 /mnt

Replace /dev/sda1 with the device name of the partition containing your Ubuntu system's root filesystem, if different.

(7) Run the command: sudo chroot /mnt

(8) Run the command: usermod -a -G admin suvala

Replace suvala with your username, if different. (This is the username on the system installed on the hard drive, and not "ubuntu" which is the username of the default user on the Ubuntu Desktop Install CD.)

(9) Run these three commands:

run these three commands:

exit
sudo umount /mnt
exit

The last of those commands quits the Terminal window.

(10) Reboot the system by clicking the power icon on the upper-right corner of the screen and clicking Restart. Make sure to remove the CD before the system boots up again, so that you can get into your Ubuntu system on the hard disk.

Having added yourself to the group called admin, you should now be able to perform administrative tasks.

If you have any problems using this method or it is not successful, please feel free to post again.

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#10

Correction: In step 9, you do not need to try to run a command called "run these three commands:". I entered that text twice by accident. Sorry about that.

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#11

Further correction (this is not a correction to the instructions themselves) -- the first paragraph of my answer should have read:

The output of "groups" indicates that you are a member of most groups
that an individually owned and managed computer's primary USER should
be in...with the conspicuous exception of "admin" ....

Revision history for this message
suvala (suvala-msn) said :
#12

I had tried below but not sure it is done or not. witch option to be choose can't understand.
I am tired now...please show me path to format my drive without affecting xp system and reinstall ubuntu.

suvala
-----------------------------------------------------------------------------------------------------------------------

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu:~$ sudo mount /dev/sda6 /mnt
ubuntu@ubuntu:~$ sudo chroot /mnt
root@ubuntu:/# usermod -a -G admin suvala
root@ubuntu:/# suvala
suvala: command not found
root@ubuntu:/# usermd -a-G admin suvala
No command 'usermd' found, did you mean:
 Command 'usermod' from package 'passwd' (main)
 Command 'uservd' from package 'userv' (universe)
usermd: command not found
root@ubuntu:/# usermod -a-G admin suvala
usermod: invalid option -- '-'
Usage: usermod [options] LOGIN

Options:
  -c, --comment COMMENT new value of the GECOS field
  -d, --home HOME_DIR new home directory for the user account
  -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP force use GROUP as new primary group
  -G, --groups GROUPS new list of supplementary GROUPS
  -a, --append append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
  -h, --help display this help message and exit
  -l, --login NEW_LOGIN new value of the login name
  -L, --lock lock the user account
  -m, --move-home move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique allow using duplicate (non-unique) UID
  -p, --password PASSWORD use encrypted password for the new password
  -s, --shell SHELL new login shell for the user account
  -u, --uid UID new UID for the user account
  -U, --unlock unlock the user account
  -Z, --selinux-user new SELinux user mapping for the user account

root@ubuntu:/# suvala
suvala: command not found
root@ubuntu:/# -u, --uid UID
-u,: command not found
root@ubuntu:/# --uid UID
--uid: command not found
root@ubuntu:/# -l
-l: command not found
root@ubuntu:/# -lsuvala
-lsuvala: command not found
root@ubuntu:/# login suvala
Password:
Last login: Sat Jan 15 11:51:54 IST 2011 on tty1
awk: -:25: fatal: cannot open file `/proc/cpuinfo' for reading (No such file or directory)
Linux ubuntu 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux
Ubuntu 10.04.1 LTS

Welcome to Ubuntu!
 * Documentation: https://help.ubuntu.com/

Your CPU appears to be lacking expected security protections.
Please check your BIOS settings, or for more information, run:
  /usr/bin/check-bios-nx --verbose

29 packages can be updated.
27 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

No directory, logging in with HOME=/
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

suvala@ubuntu:/$ sudo chroot /mnt
sudo: unable to resolve host ubuntu
[sudo] password for suvala:
chroot: cannot run command `/bin/bash': No such file or directory
suvala@ubuntu:/$ usermod -a-G admin suvala
usermod: invalid option -- '-'
Usage: usermod [options] LOGIN

Options:
  -c, --comment COMMENT new value of the GECOS field
  -d, --home HOME_DIR new home directory for the user account
  -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP force use GROUP as new primary group
  -G, --groups GROUPS new list of supplementary GROUPS
  -a, --append append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
  -h, --help display this help message and exit
  -l, --login NEW_LOGIN new value of the login name
  -L, --lock lock the user account
  -m, --move-home move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique allow using duplicate (non-unique) UID
  -p, --password PASSWORD use encrypted password for the new password
  -s, --shell SHELL new login shell for the user account
  -u, --uid UID new UID for the user account
  -U, --unlock unlock the user account
  -Z, --selinux-user new SELinux user mapping for the user account

suvala@ubuntu:/$

Revision history for this message
suvala (suvala-msn) said :
#13

Thanks a lot. After removing cd and restarting and trying to update system, it works.
Problem resolved. Thanks again.

suvala

Revision history for this message
suvala (suvala-msn) said :
#14

Thanks Eliah Kagan, that solved my question.

Revision history for this message
Eliah Kagan (degeneracypressure) said :
#15

I'm glad the problem is fixed. What follows is an explanation for why it is fixed, in spite of the error messages and confusing information you got. So you can ignore the rest of this message, if you wish.

When you performed this step, it fixed the problem (the other steps are to get to the point where you can do this, and to clean up after doing it):

root@ubuntu:/# usermod -a -G admin suvala

Nowhere in the instructions did I say to run usermod more than once, or to try to run your own username as a command. However, no harm was done when you tried to do these things--you just got errors.

The reason you got errors the subsequent times you ran usermod was that you ran it with "-a-G" instead of "-a -G" (that is, you forgot the space). However, since you had *already* run the *correct* command successfully, it didn't matter (and, in fact, was a good thing) that the subsequent commands you ran had no effect.

If you are interested, I can go through each command you ran and explain exactly what it did (or why it failed to do anything). If you want this, please let me know. However, since your problem is solved, I understand fully if you are not interested in the specific reason for the exact output you received.

Revision history for this message
suvala (suvala-msn) said :
#16

It's good to learn more. Please explain and also let me know how to create restore point,if it can be like windows xp. Also if you can, let me know path or command to delete ubuntu from hard drive and reinstall it. This will be for knowledge only. If requires in future.

suvala

Revision history for this message
Best Eliah Kagan (degeneracypressure) said :
#17

Responses to your questions, in reverse order...

"Also if you can, let me know path or command to delete ubuntu from hard drive and reinstall it. This will be for knowledge only. If requires in future."

This is really a different topic--you should post a separate Question. There's a good chance that I will answer it (I've answered a similar question before and I can modify my answer as appropriate), but if not, someone else probably will. Furthermore, if you post a separate Question for this, it will be easier for others to find it and get the answer themselves.

"Please explain and also let me know how to create restore point,if it can be like windows xp."

I'd have to look into this to provide the best answer. Again, you should post this as a separate Question (separate from the question about removing and reinstalling Ubuntu, too).

"Please explain [each command executed above and why some of them produced confusing output]."

Before you rebooted into the live CD system (on the Ubuntu Desktop Install CD), you ran the command "mount | grep ' on / '". To understand this, run the command "mount". This gives a list of volumes (including virtual partitions that don't actually correspond to anything on your hard drive, like /proc), and their mount points. A Unix-style filesystem is unified in one heirarchy; that is, unlike in Windows, where there are separate roots (e.g., C:, D:, \\hostname\sharename), on Ubuntu and other Unix-like systems all the files accessible on the system are accessible somewhere inside /. One of your partitions is mounted with / as its mount point, and then other partitions are mounted in empty folders inside the / partition. So while / represents one partition, the contents of the folders inside /media (and sometimes in other places) typically represent contents of other partitions. The mount command shows you what partitions are mounted where. See http://manpages.ubuntu.com/manpages/maverick/en/man8/mount.8.html (or run "man 8 mount") for more information on the "mount" command.

The output of "mount" was piped ("|", see http://www.dsj.net/compedge/shellbasics1.html and/or the section in http://manpages.ubuntu.com/manpages/maverick/en/man1/bash.1.html--also available by running "man 1 bash"--on "pipelines") to the "grep" command, which filters the input it receives and spits back out the lines of input that match a regular expression (http://en.wikipedia.org/wiki/Regular_expression). We needed to know the device name of the partition that gets mounted at /, so we filtered out all the lines of output from mount that didn't contain the text " on / ". See http://manpages.ubuntu.com/manpages/maverick/en/man1/grep.1.html (or run "man 1 grep") for more information on the "grep" command.

Once you had the device name of the / partition (/dev/sda6), you booted from the live CD. This was necessary because, within your Ubuntu system, you didn't have the power to make systemwide configuration changes. You needed to add yourself to the "admin" group...but you couldn't, without being in the "admin" group! Booting from the live CD enabled you to bypass the security restrictions on your Ubuntu system.

You mounted the root filesystem of the Ubuntu system installed on the hard disk, so that it would be accessible inside the /mnt folder of the live CD system ("sudo mount /dev/sda6 /mnt"). Then you "entered" this system by chrooting (or "changing root") into it ("sudo chroot /mnt"). Unix-like operating systems follow an "everything is a file" mentality; you'll notice that even the device names for partitions (like /dev/sda6) are represented as files in the virtual /dev filesystem. You were booted into the live CD system, but you needed to make configuration changes to the system on the hard disk. The "chroot" command made it so that it was as if you were inside your Ubuntu system installed on the hard disk, by treating the /mnt folder like it was /. Now, you were essentially inside your Ubuntu system, almost like when you boot into it normally...but this time, you were root, the superuser who can do anything. The ability to run programs as root with sudo is what makes a user an administrator on an Ubuntu system. See http://manpages.ubuntu.com/manpages/maverick/en/man8/chroot.8.html (or run "man 8 chroot") and http://manpages.ubuntu.com/manpages/maverick/en/man8/sudo.8.html (or run "man 8 sudo").

Now that you were chrooted into the Ubuntu system installed on the hard disk, the only remaining step was to do what you came to do, and add your user account to the "admin" group ("usermod -a -G admin suvala"). The -G flag told the usermod command that you were going to specify a list of groups, and then a username, and that you wanted the specified user to become a member of all those groups. The -a flag told the usermod command that you wanted it to *add* the user to those groups, rather than replace the current group list with that list (which would have removed the user from any groups you didn't list). The list of groups is comma-delimited, but you were only adding yourself to one group (so it was a list consisting of one element). See http://manpages.ubuntu.com/manpages/maverick/en/man8/usermod.8.html (or run "man 8 usermod").

Most commands on Unix-like systems succeed silently, which is what happened with all the commands you ran after booting from the live CD, up to this point. Not knowing this, it is understandable that you may have thought that you hadn't accomplished your task. You then tried to run your username as a command. Since there is no command called suvala, it gave you an error. Then you tried to run usermod again, but you misspelled it "usermd" and got an error. Then you tried again, but you forgot the space between "-a" and "-G", so usermod thought you were telling it to perform some action called "-a-G", and it didn't know what that was; consequently, it printed out a brief help, to inform you as to its proper use. Upon printing out the help, it exited. usermod is a noninteractive program--you never run it and then give it more information while it is still running.

It seems that, thinking that usermod was operating interactively, you tried entering several of the flags that were listed in its brief help. Since usermod was no longer running, you were actually executing these as commands...but there are no commands with those names (for example, there is no command called "-l"), so you received error messages.

Then you ran "login suvala". I don't know why you did this (perhaps because you interpreted "LOGIN" in usermod's help to mean to run that command, while actually "LOGIN" meant "<username>"), but after doing so and entering your password, you were running as suvala rather than as root. Note that this is not usually the best way to change your user identity--if you're already running as root, it's usually best to run "su <username>", and otherwise, it's usually best to run "sudo -s -u <username>". In addition to the sudo documentation I already referred to, see http://manpages.ubuntu.com/manpages/maverick/en/man1/su.1.html (or run "man 1 su") and http://manpages.ubuntu.com/manpages/maverick/en/man1/login.1.html (or run "man 1 login").

Then you ran "sudo chroot /mnt" again. But you were already chrooted into the Ubuntu system installed on the hard drive, so this time, you were asking to be chrooted into the /mnt folder **of the system installed on the hard drive**. The /mnt folder of the live CD system had the / partition of the system installed on the hard drive mounted in it. But the /mnt folder of the Ubuntu system installed on the hard drive (accessible as /mnt/mnt in the unchrooted live CD system) was empty! When chroot runs, it gives you a shell (the program where you type in commands) inside the chrooted environment. But there was no shell program inside that environment (since there was nothing at all), so chroot reported the error "chroot: cannot run command `/bin/bash': No such file or directory" and exited (that is, that invocation of chroot actually did nothing).

Finally, you ran usermod with the invalid "-a-G" flag again, and got the same error as you had gotten before. At this point, you presumably stopped, thinking that you had not succeeded at adding the user "suvala" to the group "admin" in the Ubuntu system installed on the hard drive, while in actuality, you had easily and silently accomplished that long ago.

The only part of my instructions that you (I presume) never followed was step 9:

exit
sudo umount /mnt
exit

Fortunately, that was not essential, though it would have been good form. The first exit command would have cleanly quit the bash shell inside the chroot, causing the chroot to end properly (so that you'd be "in" the live CD system rather than the system on the hard disk). The second command would have unmounted the Ubuntu partition on the hard disk, undoing the earlier command "sudo mount /dev/sda6 /mnt". See http://manpages.ubuntu.com/manpages/maverick/en/man8/umount.8.html (or run "man 8 umount"). The second exit command would have cleanly quit the bash shell running in the Terminal window, which would have had the additional effect of causing the Terminal window to close.

Throughout this post, I have talked about "entering" the Ubuntu system on the hard disk via chroot. Please note that this only applies inside the terminal in which you ran chroot--outside that terminal, the rest of the live CD system was unaffected. (For example, if you had run Firefox from the live CD's Applications menu, it would have run from the live CD system, and not from the Ubuntu system installed on the hard disk.)

Revision history for this message
suvala (suvala-msn) said :
#18

Thanks Eliah Kagan, that solved my question.