Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
1  
When you use sudo you use your own password. –  Keith Oct 21 '12 at 21:21

2 Answers 2

up vote 6 down vote accepted

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:

passwd joe

(where joe is your user name). Then reboot into your normal system, and don't forget the password this time.

share|improve this answer

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.

share|improve this answer
    
sudo uses your user password, not the root password. and besides, if an account doesn't have a password just hitting enter never actually works, in my experience. –  strugee Jun 22 '13 at 6:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.