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,

127.0.0.1 localhost
127.0.1.1 <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>

tar tips

tar

You’d think I’d just learn how to use this, but I suppose I use it so infrequently that I just can’t remember it. So here are my quick “go-to” tar references.

uncompressing

tar -xzvf filename.tar.gz

x:- eXtract
z:- parse through gzip
v:- verbose (show files)
f:- file archive

archiving/compressing

tar -cf archive.tar file1 file2 dir1
tar -czf archive.tar.gz file1 file2 dir1

notes to above:

  • you don’t HAVE to run the archive through gzip, although there’s no real reason not to. If you chose just to archive without compression, it merely means your file will be larger. This may or may not be a big deal
  • you [b]must[/b] specify a file archive (-f option), not specifying a file is an unrecoverable error and tar will exit
  • recursion is on by default, so if a directory name is specified, recursion will occur. To override that option specify (–no-recursion). Alternatively, if recursion is turned off within the environment it can be re-instated by stating (–recurse).

show me the contents

What if you just want to look at what’s in the archive?

Do a test (-t / –list) run.

tar -tvf archive.tar

This will output (list) the files to stdout without extracting the contents. Useful to see what’s in the archive.

Other useful options:

Here are just a few other useful options and command line usage options to tar that I find useful.

C:- Change to directory and extract at that location
–strip-components=1 :- use this if you need to remove the baseline directory from the archive

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

 

iproutes

routes

With regard to static routing, consider the above diagram. We have three separate networks: 192.168.1.0, 192.168.2.0, and 192.168.3.0. At first, network hosts (routers, computers, etc.) can only communicate with other hosts that are on their own network. For instance, the computer named James has a single interface on network 192.168.1.0, so that’s the only network that it can ‘see’. Initially, it will only be able to communicate with Router A.

Router A has network interfaces on the 192.168.1.0 and 192.168.2.0 networks, so those are the two networks that it can ‘see’. These are the only networks Router A ‘knows’ about, so it can only communicate with hosts on the 192.168.1.0 and 192.168.2.0 networks. So Router A doesn’t even ‘know’ that the 192.168.3.0 network exists.

Similarly, Router B can ‘see’ networks 192.168.2.0 and 192.168.3.0. When you enter a route into the table, you’re telling a host that there’s a new network it can get to, and you’re giving it the address of a gateway that it can use to get to the new network.

So to be able to contact Jesus (or any other host on the 192.168.3.0 network) from Router A, you’d enter the command:

ip route 192.168.3.0 255.255.255.0 192.168.2.2
             ^             ^             ^
           network        mask         gateway

This works because Router B can ‘see’ both Router A and Jesus. Thanks to this routing table entry when Router A wants to reach the 192.168.3.0 network, it knows it can get there via Router B at 192.168.2.2, so it sends the packet to Router B. Router B can see the 192.168.3.0 network directly, so it forwards the packet along to Jesus at 192.168.3.11.

So, now we know how to direct router A to the 192.168.3.0 network. But what if we want James to also be able to reach the 192.168.3.0 network? Well, Router A already knows how to get there, and James can already ‘see’ Router A, since they’re both on network 192.168.1.0. So we can just tell James to use Router A as its gateway to the 192.168.3.0 network. If James were a router instead of a computer, we’d use the command:

ip route 192.168.3.0 255.255.255.0 192.168.1.1
             ^             ^             ^
           network        mask         gateway

James would then be able to contact Jesus (or any host on the 192.168.3.0) network by forwarding the packet to 192.168.1.1 (Router A), which would then forward the packet to 192.168.2.2 (Router B) which would then forward the packet to its destination (Jesus in this case) via its directly connected interface.

Now, for Jesus to be able to respond to James, Jesus would need to have Router B set up as its gateway to the 192.168.1.0 network, and Router B would have to have Router A set up as its gateway to the 192.168.1.0 network. Then, any host on the 192.168.1.0 network would have a path to the 192.168.3.0 network and vice versa.

(reference: https://serverfault.com/questions/171551/help-me-understand-the-ip-route-command-for-cisco-routers )

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 192.168.0.1 to 10.0.0.1.

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 10.0.0.1 network, but the file server is sitting patiently waiting for you back on the 192.168.0.1 network.

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

>$ ifconfig
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 10.0.0.5 netmask 255.255.255.0 broadcast 10.0.0.255
 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 192.168.0.100, our computer was at 192.168.0.77. 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 192.168.0.77 up

Confirm it worked:

enp6s0: flags=4163  mtu 1500
        inet 10.0.0.5  netmask 255.255.255.0  broadcast 10.0.0.255
        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 192.168.0.77  netmask 255.255.255.0  broadcast 192.168.0.255
        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

/etc/network/interfaces

from: https://askubuntu.com/questions/585468/how-do-i-add-an-additional-ip-address-to-an-interface-in-ubuntu-14 (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
address 192.168.0.77
netmask 255.255.255.0
broadcast 192.168.0.255
network 192.168.0.0

Save and close the file. Restart the network:

# /etc/init.d/networking restart

Kicking back to Console

ctrl-alt-backspace should kill your Xwindows and kick you back to a prompt.
ctrl-alt-del will shutdown your computer gracefully

ctr-alt-F1 will send you to the first console without killing your X server so you can check errors or perhaps do some console work
ctrl-alt-F9 should return you to your Xwindows

The Pioneer

The Pioneer, Frederick McCubbin, 1904

I’m not really into art, but I find this piece amazing. Mesmerising.

I don’t even know when I first saw this piece, but when I did it blew me away. It is an amazing story told in just 3 images.

I was walking the streets of my local area a few days ago and came across an interesting house. Garden ornaments upside down, numerous pieces of dowel in trees, a tripod of sticks with a rock hanging at the end of a cord, and more. As I walked past I noticed an old gentleman in the garage working. I couldn’t help myself, I approached and began talking to him and about his house and what I had seen in his yard.

Mid sentence I looked around the garage and I saw a reproduction of this painting on the wall.

It is the only painting ever that I explicitly went to the National Art Gallery of NSW to see when it was on tour in Sydney many years ago. Beautiful. Powerful.

I’m reminded of it again tonight as I listen to Apple Music and Dire Straits’ Telegraph Road comes on. Immediately this image comes flooding into my head.

It doesn’t matter which enters my mind first, Telegraph Road and The Pioneer. I am automagically reminded of the other. The stories they share are in very similar styles.

Click on the thumbnail to view a larger version of the image. It is reproduced from the Frederick McCubbin’s—The Pioneer—Google Art Project page and can be viewed in fine detail there.

Be sure to check out the Wikipedia entry of Frederick McCubbin.

Three puzzles, three pieces missing

We have spent the last hour, probably longer, doing these three puzzles. Putting them together has been simple (I’ve been doing it for them).

However, the problem has been finding the pieces scattered between play locations, boxes, under beds, behind lounges etc. 
How crazy is it that in exactly three puzzles there are exactly one piece missing from each? 

Or is it by design? Did someone purposefully hide those single pieces?

I could be easily convinced to believe in conspiracy theories, however on this occasion, I would just say that they’re lost. 

Doh!