Change Ubuntu Hostname

Have you ever set the hostname on your Ubuntu installation only to want to change later? Here is an easy way to accomplish this and only requires changing a single line in a configuration file.

To begin, open the file /etc/hostname as root:

sudo gedit /etc/hostname

Change the text in that file to what you would like your new hostname to be and restart your computer. When the computer reboots, you will have a new hostname!

Subdomains on localhost using Apache / XAMPP

When I’m working on a new project, I often find myself wanting to setup a subdomain (e.g. http://myproject.dev) in my local environment to use while doing development. If you’re using XAMPP (or standalone Apache), this is actually a pretty easy thing to do.

These instructions should work in both Windows and Linux environments. I’ll attempt to make notes where things differ.

Step 1

Setting up subdomains requires using a VirtualHost in Apache. The file to edit is httpd-vhosts.conf.

  • On Linux, this file should be located at /opt/lampp/etc/extra/httpd-vhosts.conf
  • On Windows, this file should be located at C:\xampp\apache\conf\extra\httpd-vhosts.conf

There are two edits to make in httpd-vhosts.conf. The first edit to make is to let Apache know that we want to use VirtualHosts. To do this uncomment (or add) the following line:

NameVirtualHost *:80

The second edit is to actually create our VirtualHost. To do this, add the following to the end of httpd-vhosts.conf. Read more

VirtualBox Guest Additions on CentOS

VirtualBox is a great free, open source virtualization platform from Sun Microsystems (well, now Oracle). After installing an operating system in VirtualBox, there is an add-on product that can be installed inside of the guest operating system called Guest Additions that enables a more integrated experience between the host and guest operating systems as well as improves performance in the guest operating system. In most Windows and Linux operating systems, this is a simple install that already has all of the prerequisites needed to install Guest Additions.

However, in a standard CentOS installation, this is not the case as it is missing a few dependencies needed by the Guest Additions installer.  Unfortunately, the error given by the Guest Additions installer only tells you what is missing, but not what package(s) you need to install that will satisfy the dependencies needed.

Fortunately, it’s a pretty easy fix. ¬†All you need to do is install a few packages using yum and you’re set to go.

Run the following command as root to install the dependencies needed by Guest Additions.

yum install gcc-c++
yum install kernel-headers
yum install kernel-devel

Of course, you could always combine these into one command by running:

yum install gcc-c++ kernel-headers kernel-devel

Once this has finished, it is best to go ahead and restart CentOS to ensure that the latest kernel headers are loaded. After restarting, you should be able to run the install for Guest Additions without a problem.