Ubuntu – Why don’t I have a password for “su”? Problems with “sudo”


I have installed Ubuntu using the GUI, giving myself a password and everything. I do not intricately remember the process. However, what worries me is that I don't know the following password:

$ su
Password: <the only password I've ever created on this machine>
su: Authentication failure

I just don't know what to do. I'm not in trouble, but I just want to know what's going on here. I can also lock myself out of directories:

starkers@ubuntu:~/Desktop$ mkdir foobs
starkers@ubuntu:~/Desktop$ sudo chmod 777 -R foobs
sudo: /var/lib/sudo writable by non-owner (040777), should be mode 0700
[sudo] password for starkers: <the only password I've ever created on this machine> 
starkers@ubuntu:~/Desktop$ cd foobs
bash: cd: foobs: Permission denied

I'm just a bit confused. How can I lock myself out like this? I think sudo is the key command here. But I'm making the foobs file as open as it can possibly be via the chmod, so why does it lock me out?

Best Answer

By default, the superuser (root) account is disabled and doesn't have any password. You can create one by running:

$ sudo passwd root

You will then be able to login as root by running su using this password.

As for chmod, the correct command would be:

$ chmod 777 -R foobs

You can also use:

$ sudo -i

to login as root using your password (without creating a root password as described above).