Create a VMWare Template Ubuntu 12.04

In this article, I am going to outline a procedure to create a very basic Ubuntu VMWare virtual machine template for rapid deployment.


1. Perform the installation of Ubuntu as you would any Virtual Machine. Create an initial user called ‘cloud’

2. Install gcc, build essential and the Linux headers for the currently running kernel:

sudo apt-get install gcc build-essential linux-headers-$(uname –r)

3. Install VMWare Tools. Accept all defaults during the installation:

sudo mount /dev/cdrom /media/cdrom

cp /media/cdrom/VMWareTools-XXX.tar.gz ~

cd ~

tar zxf VMWareTools-XXX.tar.gz

cd vmware-tools

sudo ./

cd ..

rm –rf vmware-tools VMWareTools-XXX.tar.gz

4. Fully patch the operating system:

sudo apt-get update

sudo apt-get upgrade

sudo shutdown –r now

5. Clear the apt cache:

sudo apt-get clean

6. To prevent hardware related issues, remove the udev persistent rules as follows:

sudo rm –f /etc/udev/rules.d/70*

7. For the users’ convenience, lets update the locate database:

sudo updatedb

8. For good measure, lets create an administrative user in case we need access later:

sudo adduser admin (Enter details and document)

sudo usermod –G sudo admin

9. Lets make the initial users password expire immediately upon logging in as well:

chage –d 0 cloud

10. Clear out the temp directories:

sudo rm –rf /tmp/*

gesudo rm –rf /var/tmp/*

11. Now we will remove all SSH host keys:

rm –rf /etc/ssh/*keys*

12. Now we will clear the bash history to cover our tracks a bit:

history –c

13. Clearing out the logs is also a good idea. This can be accomplished as follows:

NOTE: Where ‘1’ is usually the first rotation. Check if additional rotations have occurred ‘2’.

sudo logrotate –f /etc/logrotate.conf

sudo cat /dev/null > /var/log/wtmp

sudo rm –rf /var/log/*.1 /var/log/*.gz

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.