changing hostname in ubuntu

I cloned a virtual server and late realised they had the same hostname.

No problem.

  1. change the hostname in /etc/hostname:
sudo nano /etc/hostname
  1. change the hostname in /etc/hosts:

this file will contain localhost and your old hostname. eg, localhost <new-host-name>

edit this file to suit.

Finally, change the hostname in the current session:

This can be done one of two ways. Restart the system, or issue the following command:

sudo hostname <new-host-name>

symbolic links in linux and Ubuntu

I always seem to have a tough time getting symbolic links right and often finding myself either Googling them or running test link after test link until I nail it. Normally I follow the mantra:

command {something} {somewhere}

such as:

mount /dev/sda1 /media/mydrive

/dev/sds1 being the “something” and the /media/mydrive being the somewhere

But with symbolic links, what is the something? Is it the symbolic link? is it the target? The somewhere, is that the target or is that the symbolic link? And the man page offers no help (at least not in my interpretation of it).

I’ve realised tonight the first error I’ve been making is forgetting you should explicitly set a full path to the target object (folder or file).

I’m often creating symbolic links to directories, usually remote and so a symbolic link in my home directory fits the bill.

What’s the correct syntax?

ln -s {/path/to/folder} {linkname}

ln -s /media/usbkey ~/usbkey

ln -s /run/user/1000/gvfs/afp-volume:host=DSBOX.local,user=dav3,volume=desktop/remotedir remotedir


Adding additional IP Address to ethernet interface

network card

Scenario: You have several devices within your network, you’ve changed the address range for the network but you’ve forgotten to change one in particular. It’s easier to log into the device than to physically attend to it (it may be headless, it may not be in your immediate vicinity, or you’re just to lazy to get out of your chair to do it.

Q. How do you log into a network device that isn’t on your subnet?

A. You create an alias IP address for your current interface within the scope of the IP address you need to hit.

In this example we’ve moved a network from a to

The router has been configured, all the devices have been configured and you’re up and running but realised you forgot the file server in the garage. Your whole network is now setup on the network, but the file server is sitting patiently waiting for you back on the network.

Here’s how you would do it in linux (Ubuntu):

>$ ifconfig
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet netmask broadcast
 RX packets 6406862 bytes 7485766742 (7.4 GB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 3920089 bytes 1566938600 (1.5 GB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

The old server is at, our computer was at You can use any IP address that is not the device you want to connect to, and that is still within the same subnet range.

$ ifconfig enp6s0:0 up

Confirm it worked:

enp6s0: flags=4163  mtu 1500
        inet  netmask  broadcast
        ether 11:22:dd:99:4e:ee  txqueuelen 1000  (Ethernet)
        RX packets 6413204  bytes 7488178719 (7.4 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3925411  bytes 1568449079 (1.5 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp6s0:0: flags=4163  mtu 1500
        inet  netmask  broadcast
        ether 11:22:dd:99:4e:ee  txqueuelen 1000  (Ethernet)

note: this won’t survive a reboot. But for most intents and purposes, this will suffice. You can log into the file server and change the IP address and jump back out.

To make it permanent we will need to edit


from: (modified only to match the example above)

# vi /etc/network/interfaces

Append the following to the file (This is in addition to existing information, not a replacement for it)

auto enp6s0:0
iface enp6s0:0 inet static
name Ethernet alias LAN card

Save and close the file. Restart the network:

# /etc/init.d/networking restart

using variables on the command line

Following on from my last example of copying a SSH public key to a remote computer, this is something I need to do when setting up a new computer. Setting up private/public keys for SSH just make logging in that little bit smoother.

When you need to rerun the command, you need to load it up, edit it and resubmit it. Unfortunately (although it’s probably possible) I don’t know an easy way to bring up a previous command and edit it in-line so that I can send it again without actually sending the command again before doing so.

Instead, Load a variable into the command line and change it next time.

-- 11:03:01 -- MBP:~ madivad$ ssh minixbmc
Last login: Mon Apr 25 18:23:18 2016
minixbmc:~ madivad$ exit
Connection to minixbmc closed.
-- 11:03:17 -- MBP:~ madivad$ remote=minixbmc
-- 11:03:26 -- MBP:~ madivad$  history | grep remote
  439  remote=he1000
  440  cat ~/.ssh/ | ssh madivad@$remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  502  remote=minixbmc
-- 11:03:34 -- MBP:~ madivad$ !440
cat ~/.ssh/ | ssh madivad@$remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
-- 11:03:40 -- MBP:~ madivad$ ssh minixbmc
Last login: Tue Apr 26 11:03:12 2016 from
minixbmc:~ madivad$

For example, in the above session, for simple commands, I would being the history file up, reissue line 440, then edit, then issue it again. In this situation, it would have the effect of loading the key again, and that’s not what I want to do.

  • Breaking it down, I logged into the remote machine and realised a password was needed,
  • I logged out,
  • I set the “remote” variable,
  • looked for the relevant history command (I knew it had the word “remote” on it),
  • I re-issued that line, and
  • then tested the login.
  • No password was needed, the command was a success.

This could be done with other things as well where you’re always changing one element on the line (or multiple elements, and use multiple variables).

For a more simple and silly example, let’s create a quick update and install script for ubuntu:

upstall=’htop multiwatch’
sudo apt update && sudo apt install $upstall

Instead of typing the whole line next time, I can just type the new apps to install in the “upstall” variable and reissue the command (in this case, using arrow up a couple of times, or grabbing the index from the history file).

$ sudo apt update && sudo apt install $upstall
[sudo] password for madivad:
Hit:1 xenial InRelease
Get:2 xenial-updates InRelease [92.2 kB]
Hit:3 xenial-backports InRelease
Get:4 xenial-security InRelease [92.2 kB]
Fetched 184 kB in 1s (101 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
byobu is already the newest version (5.106-0ubuntu1).
htop is already the newest version (2.0.1-1).
multiwatch is already the newest version (1.0.0-rc1+really1.0.0-1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

If I then later want do another update and install something else, I can re-set the “upstall” variable and arrow up or grab it out of history.

11:53:44 madivad@he1000:~$ upstall=jq
12:03:44 madivad@he1000:~$ sudo apt update && sudo apt install $upstall
Hit:1 xenial InRelease
Get:2 xenial-updates InRelease [92.2 kB]
Hit:3 xenial-backports InRelease
Get:4 xenial-security InRelease [92.2 kB]
Fetched 184 kB in 2s (91.0 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
jq is already the newest version (1.5+dfsg-1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
I'm a simple man, I like simplicity. And although there are probably better ways to do this, for the time being, this is how I'm getting the job done. It works well for me, but I'm open to any suggestions and/or improvements.

As I said, not the best example, but hopefully you get the idea.

sudo please

I stumbled across this alias quite a few months ago, but it was under a different name then.

I wanted to find it today and Google searches brought up a whole heap of malicious finds on it, aimed at targeting the unsuspecting newbie to linux. Obviously there are some very dangerous linux commands and so I’m not going to repost them here. Or maybe.

In linux, when you need special permissions to run a command, you’ll get a “permission denied” error. The standard response to that is to “sudo !!” (pron: sudo bang bang) which runs the last command again. Everyone who’s ever used linux will know this can get frustrating.

The I found “fuckit” (or it could have been just “fuck”, I can’t remember which).

When you forget to type sudo, and you’re prompted your permission has been denied, you can issue the expletive whereby the command runs as expected. The funny thing about this, is that when this does happen, it is the sort of thing you are probably thinking, and the expletive does it’s job.

In looking for it today, I found that someone else uses the “please” alias instead. There’s no difference, they both do the same job. It’s just how you feel you want to talk (type) to your computer at the time.

To achieve this, you need to create an alias:

alias please='sudo $(fc -ln -1)'
alias fuck=please

Only include the second line if you feel so inclined. I did because initially you can be all like “please?? Oh thank you understanding computer.” but after a day of permission denied errors, you might be more inclined to just yell at the screen, in which case, the second line is more appropriate.

Creating the alias alone won’t make it persistent. To do that, add the alias to the end of your ~/.bashrc file, or in my case, I’m running ubuntu and you can add it to ~/.bash_aliases instead.

Youtube embedded videos in WordPress not working

You’ll notice above that there is a youtube URL on the first line… it hasn’t embedded within the post.

UPDATE 2015-12-10: it’s working now, is it a WordPress 4.4 thing? I have disabled a LOT of plugins for the moment, I’ll come back and revisit this in the next couple of days. I have spent many hours working on this problem over the last few months and having just found I’ve had other issues, I’ll revisit this again

Embed the URL without embed tags
Embed the URL without embed tags

Also, I have just learned today that the youtube style of embedding without embed tags have been extended in WordPress 4.4 to include URLs to your own WordPress site (and possibly others).

Are you finding your{videocode} youtube links not embedding correctly or working in WordPress?

The correct format for the link is any one of the following:{videocode}{videocode}
[ embed]{videocode}[/embed ]

(there is a space before the embed in the above one to have it display correctly)

There are three things to watch out for to ensure this works. And if you do each of these, then you don’t need to use the [ embed ] code you see in the third example above. They are:

  1. Ensure the URL is on it’s own line
  2. Ensure you use HTTP in lieu of HTTPS (*1)
  3. Ensure the link does NOT appear on the first DISPLAYED line of the content

*1 : this is not a big one, since it seems most of the time it works, but for some reason it didn’t when I used it on this particular occasion.

I say DISPLAYED because in an effort to fix this, I tried putting a blank line for the first line. The problem persisted. It also didn’t help to include just a full-stop (period) there either.

I do believe it could also be theme related as this theme does not use the different post type options that is present in the newer themes. And from what I did find elsewhere, selecting different options in that meta-box can alter this behaviour. I will probably be changing themes in the coming months as I work further on my own custom theme, but for the time being if I want it to appear on the first line, I will use the appropriate [ embed ] code above (with the space removed!). This was not a problem I found documented anywhere else, so hopefully you have found this useful!

WordPress media library limited to 10MB

Screenshot 2015-09-14 11.23.102
I think I’m a little over my quota!

Have you ever noticed this in your blog? It’s never been there before, but it appeared in the last day or two. At the time I wasn’t sure how or why. It’s my blog hosted on one of my web hosting accounts, and I have no shortage of space. So why was I getting this warning?

Screenshot 2015-09-14 11.35.24Worse yet, I went to add a photo, and this happened. That’s when I realised the quota was real!

My first question is, what dickhead gave me such a quota!

My first action was to work out where it was imposed.

Then I found who the right royal dick was. It was yours truly!

I’ve been doing too much playing in the back end and I at some point, and for some unknown reason, have turned it on.

I’m running WordPress Multisite and it’s a setting hidden in the Network Settings.

To navigate to it, click on My Sites in the top left corner, and select Network Admin. Then from the next menu select Settings.

secret hiding place for the 10MB upload quota
this little setting on the right… Make sure you turn it off! :)

And that’s it! Once, you clear that little baby, you’ll be able to upload to your little hearts content.

UPDATE: It looks like I wasn’t the only one who’s ever done this! 

WordPress MultiSite & sunrise.php

Are you getting the above error message as well?

After doing a fresh install and enabling multi-sites I couldn’t see the Domain Mapping and Domains sub-menu options under Network Admin / Settings.

I loaded up my trusty editor and confirmed

define('SUNRISE', 'on' );

was in fact in the file. It was slightly higher than where it said, it’s not important, but I moved it anyway, and I still got the error.

I checked and sunrise.php was in fact in the correct location under /home/public_html/wp-content/sunrise.php

So how did I fix it?

The problem was, it was the incorrect (read:old??) sunrise.php file!

Copy the correct one from:


and replace the previous one, and reload your admin page. You will now see the welcoming domains page :D

If you want to find out more as to why it happened, and how it is that my sunrise.php got “moved” or “re-moved”, it was due to a conflict by domain mapping plugins. I’ll be blogged about it in the near future and it will appear here (currently in draft and not published).

Chrome 45 attacks WordPress admin menu

wordpress-chrome-broken-mergedChrome has taken a turn towards the dark side and has attacked the WordPress admin menu. Luckily there’s a simple workaround and a bug report has been filed which will hopefully lead to a fix soon!

The bug is specifically Chrome related (you can read more here) and they are currently working on a fix that should see it’s way into version 46 stable.

There are several fixes for this bug, rated in (my) order of best solutions:

  1. visit: chrome://flags/#disable-slimming-paint (<< unclickable, you’ll have to enter it yourself :) ) in your browser and select ENABLE (from comment #42). The quickest and easiest solution.
    Screenshot 2015-09-10 08.09.28
  2. Add the following action to the WordPress’ functions.php file (from comment #37):
    function admin_menu_fix() {
      echo '<style>
        #adminmenu { transform: translateZ(0); }
    add_action('admin_head', 'admin_menu_fix');
  3. Collapse and re-Expand the Admin menu is a temporary fix, as is refreshing the screen, but that’s a PITA.
  4. There is also a chrome extension that also deals with this issue: more can be found out here
  5. There is also WordPress plugin, and it will ALSO do the trick. I don’t mean to detract from the developer, but I am very anti installing unnecessary plugins if you really don’t need to. But the fact I haven’t provided you a link only means you’ll spend longer looking for it than you would have spent if you just go and change the option in Chrome settings.
  6. Wait for a fix, which SHOULD be in appearing in an update near you soon :)

#3, and #6 really aren’t options. #4 and #5 are workarounds that will only help users who experience the problem with WordPress and no other sites that are also affected (although this does appear to be somewhat limited), leaving #2 (which is also only a WordPress fix) and is way too much overkill.

And the winner is?

The best solution is #1 and this will take you all of about 5 seconds. It is the BEST solution because this fixes other areas the bug affects (which for me) is my gMail menu where things haven’t been right for a while but a refresh fixed it. In fact, refreshing the page in WordPress also fixes it, as does collapsing and expanding the admin menu.

Anyway, you AND I have spent far too long on this post! So go ahead, open the above in your browser and fix the menu :)


Bluetooth connecting to Phone Audio only, not Media Audio

beats-studio-wireless-headphones-xlHas this ever happened to you??

It was annoying me today. I was going for a long walk and I wanted to enjoy my favourite game (Ingress—come join the resistance!), but the audio wouldn’t come to my headphones. I had to sit down and work this out.

I’d realised recently that my car was only playing Phone Audio through the bluetooth which left the phone’s media on the phone. I remember thinking at the time, “I don’t remember doing that”, but since it suited me (I don’t play phone media through my car stereo), I didn’t pursue it. In fact, I’d seen the setting before and just assumed that at one time, I must have actually changed it.

But when I check the Beats headset, it was also set to Phone Audio only.

No problem, I tapped the Media Audio checkbox and waited… and waited… and it times out, unchecking the box.

Strange, I “forgot” the headset and repaired the two.

Still no media audio.

I then turned off the headphones and turned them back on, reconnected them and STILL no media audio.

I had initially thought it was a problem with the headset, so I’m googling Beats Wireless problems, then I thought about the phone, Samsung S5, but I was drawing a blank. Then just googling bluetooth problems generally with phone and media audio I find that I am certainly not alone!


Fix: Reboot the phone! 

Sure enough, I reboot the phone, reconnect the headphones and Media Audio has returned.

I then went about fixing the amount of green that had begun to pollute my area. :D