I installed a Ubuntu and it only has a user. I can login to the system without login. It doesn't ask me for un/pwd. but when I am in, and I want to run some commands as root (sudo), it ask for password and not allowing me to run it. No password works. How can I find password for this user or root?
By default, on Ubuntu, there is no password for the root account. To run a command as root, you must run
sudo, which asks for your own password. The Ubuntu installation creates one account with
sudo privileges and asks you to enter a password for that account.
If you've forgotten the password, you'll have to change it. First, you need to be able to run a command as root (as a non-privileged user, you'd have to enter the current password to change it). The easiest way to do this if you aren't fluent with the Linux command line is to boot the Ubuntu installation media and select “rescue” rather than “install” at the menu. Alternatively, at the boot menu (you may need to press and hold
Shift when your computer is booting, after the BIOS has initialized, to see the boot menu), select the “rescue” option or edit the command line to add
init=/bin/bash at the end — see Lost Password in the Ubuntu community documentation for more details (this page may not be very up-to-date).
Once you get a command line as root, run this command to change your password:
joe is your user name). Then reboot into your normal system, and don't forget the password this time.
I thought Ubuntu forced you to make up a password for root when you install it but obviously not. Try hitting 'return' instead of entering a password when you sudo and see if that works. If so, then you just haven't set a password for root and 'return' will work for anyone. Not a good thing.
You could log in as root, and type 'passwd' (without the 'o') to create a new password for root.