Recover from lost root password on xubuntu

The following was executed on xubuntu running in a VirtualBox VM inside a MacOS X Maverick.

user@xubuntu64:~$ uname -a
Linux xubuntu64 3.11.0-19-generic #33-Ubuntu SMP Tue Mar 11 18:48:34 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

You need to have access to the grub menu.

1) boot your VM
2) at the grub menu, press “e” on the ubuntu entry
3) go to the line starting with linux and add at the end “rw init=/bin/bash” (if you have “ro” at the end, remove it – don’t leave both ro and rw)
4) press cntrl-x to boot the VM
5) you will end up at the bash shell (no password asked)
6) verify that the root filesystem is mounted in rw mode (touch /etc/aa; rm /etc/aa)
7) execute “passwd root” and provide the new password
8) execute a “sync” (quite certainly useless but it won’t harm)
9) send your VM a cntrl-alt-del via VM menu (here reboot, init, halt and shutdown commands will not work and if you type “exit” the kernel will panic)

Screen Shot 2014-06-02 at 12.00.05

Screen Shot 2014-06-02 at 12.00.13

Screen Shot 2014-06-02 at 12.00.29

Screen Shot 2014-06-02 at 12.01.39


Screen Shot 2014-06-02 at 12.02.45

Screen Shot 2014-06-02 at 12.04.33

Executing “service docker status” I get “docker dead but subsys locked”

I did a

killall docker

I should have used the service command instead.
After the killall, if I check the status of the service I get an unusual message:

[root@steve run]# service docker status
docker dead but subsys locked

A lock file has been left behind:

[root@steve run]# cd /var/lock/subsys/
[root@steve subsys]# ls -l
total 0
-rw-r--r--. 1 root root 0 May 30 20:03 docker
[root@steve subsys]# fuser docker
[root@steve subsys]# rm docker
rm: remove regular empty file `docker'? y
[root@steve subsys]# service docker status
docker is stopped

In /var/run there was also a docker.sock file which I also removed.

This workaround applies to any service either killed by hand or crashed which had a lock file in /var/lock/subsys.

A shell question about metacharacter expansion I should have answered correctly (but I didn’t)

Got asked this question and miserably failed.

“I am at a shell prompt and I type “cp a*. What happens?”

What happens depends on what files and directories exists in your current directory.

One scenario is the following.

[root@steve tmp]# ls -l

total 4

-rw-r–r–. 1 root root    0 May 30 22:00 a-file01

-rw-r–r–. 1 root root    0 May 30 22:02 a-file02

-rw-r–r–. 1 root root    0 May 30 22:02 a-file03

-rw-r–r–. 1 root root    0 May 30 22:02 a-file04

drwxr-xr-x. 2 root root 4096 May 30 22:03 a-file05


Note that despite the name, a-file05 is a directory.

Now execute:  “cp a*”

The shell has not complained and it has done something.

If you ls the a-file05 directory, you will see that the 4 files have been copied there:

[root@steve tmp]# ls a-file05

a-file01  a-file02  a-file03  a-file04

This works because a-file05 – the directory – is the last in the ordered list, so when the “*” is expanded it’s the last one and the copy can work.

If you had instead:

[root@steve tmp]# ls -l
total 4
-rw-r--r--. 1 root root 0 May 30 22:00 a-file01
drwxr-xr-x. 2 root root 4096 May 30 22:07 a-file02
-rw-r--r--. 1 root root 0 May 30 22:02 a-file03
-rw-r--r--. 1 root root 0 May 30 22:02 a-file04

this would not work:

[root@steve tmp]# cp a*
cp: target `a-file04' is not a directory


MySql: calculate the size of all DBs in your instance

SELECT table_schema "DB NAME",
 Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB SIZE (MB)"
 FROM information_schema.tables
 GROUP BY table_schema;

Yauatcha, Soho, London

April 2014


Second time at this posh and stylish Chinese Dim Sum restaurant.

First time we had managed a ground level table for an afternoon tea, this time unfortunately we had to go for a table in the dim (no pun intended) underground floor.

To me the service is a bit too attentive and there are a lot of questions and chatting – not being the most sociable of persons I am not into so much interaction.

We had Wagyu beef puff, steamed aubergine with chilli sauce (more paste than sauce), sticky rice and some vegetarian dishes

The puffs were excellent, perfectly fried. The meat inside was so tender it melted in my mouth. The taste was great.

The aubergine were very hot and it would be nice if they served some rice with it.

Lunch for 2: 59.85GBP