sudo: can’t open /etc/sudoers: permission denied

The sudo command checks the permission of the /etc/sudoers file and also the contents of /etc/sudoers.d/ before allowing you to use the sudo command.

For example you might be warned:

sudo: /etc/sudoers is mode 0777, but should be 0440

or perhaps:

sudo: can't open /etc/sudoers: permission denied.
sudo: no valid sudoers sources foundm quitting

Therefore, if you don’t have root login (which is generally good security practise) then you might not be able to change the permission back without dropping into recovery mode.

1 – Reboot the machine

2 – Select boot from recovery more

3 – fsck the disk which will then mount the disks as read/write

4 – Drop to root shell

5 – chmod 0400 /etc/sudoers

6 – reboot the machine and you are fixed

Apache 2.4 Failed To Start AH00016: Configuration Failed

One of our Apache 2.4 web servers strangely stopped working and didn’t want to come back up. I tried to start it but it came back with a vague error message:

$ sudo service apache2 start
Starting web server
apache2 Action 'start' failed.
The Apache error log may have more information.

A quick look in /var/log/apache2/error.log just showed nothing useful:

$ tail var/log/apache2/error.log
AH00016: Configuration Failed, exiting

So, I ran the Apache configuration check tool on the configuration files but the syntax was okay.

$ sudo apache2ctl configtest
Syntax OK

This means that there isn’t anything wrong with the syntax of the Apache config and I generally find that this means either an SSL certificate isn’t installed incorrectly or there is something wrong with a more general configuration file. To find which host had configuration file problems – I used the strace command. This is really good because it shows all of Apache’s interactions with the file system. Therefore you can see the last file Apache opened before failing.

sudo apt-get update
sudo apt-get install strace
sudo strace -f apache2ctl start

The output from strace is quite large but you can clearly see where Apache failed.

.....
[pid  6068] munmap(0x7f45c6c38000, 4096) = 0
[pid  6068] write(11, "[Sun Oct 05 07:35:44.207805 2014"..., 189) = 189
[pid  6068] write(2, "AH00016: Configuration Failed\n", 30) = 30
[pid  6068] select(0, NULL, NULL, NULL, {0, 10000}) = 0 (Timeout)
.....

and just before this was this…

[pid  6068] munmap(0x7f45c6c38000, 4096) = 0
[pid  6068] open("/etc/ssl/private/a_website_ssl.key", O_RDONLY) = 45
[pid  6068] fstat(45, {st_mode=S_IFREG|0644, st_size=1704, ...}) = 0
[pid  6068] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f45c6c38000
[pid  6068] read(45, "-----BEGIN PRIVATE KEY-----\nMIIE"..., 4096) = 1704
[pid  6068] close(45) 

This enabled me to quickly idenfity which ssl certicate was causing the problems and disable the site which was using that key.

sudo a2dissite a_weebsite.conf

I hope that someone finds this useful.

how much does it cost to distribute ghostscript commercially?

I’ve been working on a commercial project where we would have liked to use Ghostscript. To use ghostscript in a commercial settings (i.e. to distribute it alongside binary code) you need to have a license.   At the time of writing (September 2014) – the costs for this are rather prohibitive:

There is a minimum $8000 per quarter and a $5000 set-up fee. This fee can increase depending your business usage.

Wow. That’s too rich for me. Time to find another pdf lib.

How To Recover / Get Your Music From Your IPod / IPad / IPhone

It’s a classic mistake. You buy an ipod, import all your music into itunes, sync it onto the ipod… then at some point loose the computer. Suddenly, your ipod has all of your music on it and you can’t get it off. Don’t panic… there is hope but it does cost you $35. Yes, there are other solutions to this problem but this is something anyone can go.

Install itunes on a new computer
You will need the drivers for your ipod and therefore you need to download and install itunes.

Stop itunes automatically syncing
Once you have installed itunes, you need to make sure that it doesn’t automatically override the music on your ipod by automatically syncing nothing over the top. To this go to:

Edit -> Preference -> Devices and check ‘Prevent Ipods… from automatically syncing’.

Buy a copy of iExplore
Iexplore is the program which makes this really easy to do. The only draw back is that it costs $35. Personally, I think this is completely reasonable given that it saved over 2,000 songs for me. Buy a copy of the software, download and install it.

Plug in your device
with a usb cable.

Open Iexplore
Browse to device -> music -> select all the tracks and then you can transfer either to itunes or a folder.

Job done.