Skip to content

OS X gone ; Hello Linux on a MacBook pro !

Installing Linux on MacBook Pro.

I find Apple to be a closed operating system that weirdly uses Unix at its core.

I have recently bought a 2nd hand 2007 MacBook Pro that has the following spec: –

  • 17″ Screen
  • 2 GB Memory
  • 160 GB Hard Drive
  • 2.6 GHz Intel Dual Core Power Based Processor
  • OS X 10.5.8

I intend to install a Linux distribution to replace the current OS X 10.5.8 that is already installed on the MacBook Pro.

My current understanding to do the above is that I need to do the following: –

  1. Put the Linux Mint 14 Nadia 32 bit distribution in the drive and boot this DVD up to install it onto the system. I found out that my CPU was a 32 bit processor by checking this website out.

I booted up the Apple MacBook Pro and held the “alt” button after I heard the laptop start sound and clicked to boot from the CD drive which said “windows”. To be honest that was enough to bring up the Live CD to have a play with and then I went ahead and installed Linux Mint onto the machine. Now i’m happy:)

Oh for anyone that might want to do this, make note that to right click you need to put 2 fingers on the touch pad and then click.

PS. I was going to install Yellow Dog Linux PowerPC edition onto the MacBook Pro but for some reason it would  not bootup from the DVD, ah well as long as I have a Debian/Yum based installation distribution, I’ll be alright.

Setting Correct time on Host Computer

On my Centos Server 6.3 I have always had the wrong time, its always been the current time plus one hour. I changed this today by defining the time: –

prompt> date -s HH:MM:SS

for example if I wanted to keep the same date but just change the time to 5pm I would do so like: –

prompt> date -s 17:00:00

Simple to do, I’ve had this on my todo list for my server for a long time, found out through the manual and all in all it only took 5 minutes. Now I have the correct time on my server!

Ready, Set, Rsync !

Rsync is a useful command that I have seen a lot of people comment about being really good for incremental type backups for both personal and enterprise systems. So I’ve taken it on myself to get to grips with rsync and use it much more rather than use the normal copy (cp) command.

So from the manual of rsync I have learned that we can archive the permissions/links/attributes by using the -a argument, we can compress the data being transferred from source to destination by using the -z argument, I will want the parent and child folders to be copied so I will be putting recursive copying on by using -r argument, we can get the command to tell us what it is doing by adding verbosity with the -v argument and to make sure to understand the output I want to display the output as human friendly with the  -h argument. I will also use the -P argument so that I can see the progress of the files being copied too. Using these 6 main arguments copying should not be too difficult at all.

Example 1 (I would use this example if I was copying from/to the local system)

prompt> rsync -azrvhP absolute_path_of_source absolute_path_of_destination

Example 2 (I would use this example if I was copying from/to different servers)

prompt> rsync -azrvhP -e ‘ssh’  absolute_path_of_source user@hostname:/path_of_destination/

# Note in the 2nd Example that I used the argument -e to tell the local computer to run this command through ssh which I use to connect to the remote server

Not too difficult once you have tried it a few times and the beauty of using rsync is that it will do an incremental copy to the destination which means that it will check all the files you are going to copy over and will only copy them over if the source files are newer than the destination files if present.

What’s on VNC tonight?

Here is a quick guide on how to use VNC to view remote desktops.

To install VNC onto server: –

prompt> yum install tigervnc-server

Set the VNC password for the user, this is a security measure: –

prompt> vncpasswd

Configure VNC so that it can be used: –

prompt> vi /etc/sysconfig/vncservers

Make sure to replace the username with a specific user for the VNC to connect to. Uncomment these two lines and save.


VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -localhost”

Now you are ready to startup the VNC server.

prompt> vncserver

Once you execute the above command it will start the VNC server on port 5901 and display number 1 and so on and on when you create more display numbers with VNC servers.

Make sure to allow your firewall to let port 5901 tcp traffic through so that VNC clients can access this VNC server: –

prompt> system-config-firewall-tui

# Then proceed to customise > Forward > Add > Port Range: 5901 & Protocol tcp > OK > Close > OK > Yes

Then all you need to do is go to another machine install the VNC client like so: –

prompt> yum install vncviewer

Then use the command below to create a VNC session between the current machine that has vncviewer installed on it and the machine where the VNC server is installed on (replace the hostname below with the hostname of the server that has the VNC installed on it, you can always type hostname on the server to find this out): –

prompt> vncviewer hostname:5901

You can always see how many VNC servers you have running on the system by logging onto the server it is running on and doing a:-

prompt> vncserver -list

Furthermore you can terminate the specific VNC server by killing it, in the example below it will terminate the VNC server that is on the display number 1: –

prompt> vncserver -kill :1

I made sure I had installed xterm so that I could access it when I did a VNC session from the client to the server. First time I was trying it out I was getting a lot of problems and made a few mistakes but with persistence and renewed effort I learn’t it:) !

Furthermore once I had the VNC server setup as above I could also use my mobile and any other computer regardless of platform to connect to the VNC server

Quick Tip to find out what Linux Distribution you are using

Here’s a useful command I have come across to find out what linux distribution and release you are using.

This works both on Debian based distro’s (deb) and Fedora based ‘distro’s (rpm).

To find out what linux distrubtion and release you are using you can use the command lsb_release: –

prompt> lsb_release -a

This is a pretty quick and easy tool to use, this could prove very useful!

Installing PHP

Right to round off my knowledge of LAMP, i will now install PHP from source on to the Centos Webserver.

So first things first, lets install the latest PHP from the main website which is PHP 5.4.3: –

Installation of PHP on Centos Server

prompt> wget -v

Unzip the compressed file and the archive: –

prompt> tar -zxvf php-5.4.3.tar

Now we need to make sure that the Apache Extension Tool is installed. For more information regarding the Apache Extension Tool please visit: –

We can check that it is properly installed by: –

prompt> /usr/local/apache2/bin/apachectl -l | grep mod_so

As long as you get a result listing mod_so then you are okay, if you do not get anything feedback from the prompt then this could be a sign that the Apache Extension Tool has not been installed properly.

We need to make sure we have the libraries to install xml and html applications that is a dependency for php, install it by typing: –

prompt> yum install libxml2-devel

Okay now we can start to install PHP, make sure you are in the folder and then type the following: –

prompt>./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql

prompt> make

prompt> make install

Now that PHP has been installed, we need to setup out php.ini file as specified in; –

To setup the php.ini file to be used we do the following; –

prompt> cp -v php.ini-development /usr/local/lib/php.ini

During the make install in the previous step it actually edited the httpd.conf file to load the module which is php5. Now we need to configure the Apache Directives to make sure that PHP files are parsed by the Apache Webserver and only specific files are parsed by the Apache Webserver for security reasons. So let’s put the following into the httpd.conf file which is located at /usr/local/apache2/conf/httpd.conf and make sure to add a tab to the second line before starting to type: –

<FilesMatch \.php$>

SetHandler application/x-httpd-php


Okay, now that Apache Webserver has support for PHP. We can now test that Apache Webserver does support PHP files. Lets use the simple tutorial from PHP’s main website ( ), so make sure to create a file with a .php extension, e.g. test.php and put the following source code in it and save it:-

<?php echo ‘

This serves as confirmation that this webserver supports PHP

‘; ?>

Navigate to the above file using your Internet browser (e.g. http://localhost/test.php) and hit return. This should show a webpage that echo’s the above message which means that PHP works:)

Backing up Mysql Databases

Now to backup the databases I will use mysqldump, this is one of the preferred ways to backup as recommended by mysql (

To create a backup of a specific database you do: –

prompt> mysqldump -u bob -p –databases name_of_database > backup_of_database.sql

The above will create a backup of the database on the form of backup_of_database.sql

Now to restore the database into mysql if it ever got deleted you would do: –

prompt> mysqldump -u bob -p –databases name_of_database < backup_of_database.sql

Make sure that the database name has been created in mysql before you start restoring a backup otherwise you will receive an error message saying that it can’t find the database. Note that the only change to the commmands are the redirection, i.e. > and <

You can always create the database by using the following command: –

mysql> CREATE DATABASE name_of_database_you_want_to_create;

Quite simple stuff but it works well. You can always archive and compress using tar to make the backup data size smaller and to archive multiple backups into one archive. Furtermore if you look at the man page you can quite easily backup all the databases with a simple argument too.


Onward on my LAMP journey to Mysql (

You can download mysql from the following website (I downloaded the Mysql Community Server): –

I will download and install the following to install mysql : –

prompt> wget -v     # This is the development libraries for mysql

prompt> wget -v    # This is the mysql client

prompt> wget -v      # This is the mysql server

I then proceeded to install : –

prompt> rpm -ivh MySQL-devel-5.5.25-1.linux2.6.i386.rpm

prompt> rpm -ivh MySQL-client-5.5.25-1.linux2.6.i386.rpm

When i was trying to install the server i received conflict errors saying that it will not be installed as mysql-libs-5.1.61-1.el6_2.1.i686 is installed. So what i did was remove this old package by: –

prompt> rpm -ev –nodeps mysql-libs-5.1.61-1.el6_2.1.i686

And then proceeded to install the mysql server: –

prompt> rpm -ivh MySQL-server-5.5.25-1.linux2.6.i386.rpm

I started mysql by: –

prompt> service mysql start

Did a quick check to make sure that it will start at boot too: –

prompt> chkconfig –list mysql

Did the following to confirm what version of mysql was installed by asking the mysqladmin application: –

prompt> mysqladmin version

prompt> mysql

This immediately logged me into the mysql database as a unprivileged user (without the access to create or modify records) without needing to give a password.

Notice how the prompt has changed to mysql> this tells us that we are in the mysql database. Doing the following command will give more detailed information about who is logged into the database amongst other information: –

prompt> status

Now exit the database as we have verified it is working correctly

prompt> exit

Now as I can logon to mysql without any passwords this likely means that i can logon as the user root that will have all privledges available to create, delete and modify any records on mysql. For this reason I will login as the user root and change the password so that this user account is sercure: –

prompt> mysql -u root

now that i am logged in as root on mysql, i will change the password for root: –

-> ‘root’@’localhost’ = PASSWORD(‘type_password_here’);

After I hit return i got confirmation that my commands were correctly carried out by feedback from mysql: –

Query OK, 0 rows affected (0.00 sec)

Now if i try to login as root without a password mysql will have none of it and will not let me in as there is now a password assigned to the root user. So i have to login as follows: –

prompt>mysql -u root -p # Hit return and then prompt will ask for a password, type it in, hit return and you are in!

Next thing i will do is create an account called bob that i will use from here on out to create, delete and modify mysql, whilst still logged in as root : –

mysql> CREATE USER'bob'@'localhost'IDENTIFIED BY'type_password_here';

mysql> GRANT ALL PRIVILEGES ON*.*TO'bob'@'localhost'

# This grants bob access to add, remove and modify all databases

Again exit mysql and now login as bob with the new password to make sure bob account can be accessed: –

prompt> mysql -u bob -p

Now typing the following will show us what databases the account bob has access to: –


You should see the test database available, lets use that database: –

mysql> USE test # the prompt should come back with Database changed, this acts as acknowledgement that we have changed to the test database

As an example we will create a database called shopping_trolley and build the database up with records: –

mysql> CREATE DATABASE shopping_trolley;     # This creates the database

mysql> USE shopping_trolley #  This selects the database so that we can add records specifically to this database

If you ever want to make sure what database you have selected and are working on then all you need to do is type: –


From here on out it might be worth me telling you what the structure of the record is. In each Database we have many Tables and in those Tables are loads of Columns that contain Data. To be honest keep it simple like this and it makes it more easier to understand!

So far we have created our database, but we have no tables in it yet, we can confirm this by: –


What we’ll do is create a table that we intent to keep a shopping list for certain vegetables to buy, we will include the following columns in the vegetable table: –





We will create the vegetables table and the above columns in it by: –

mysql> CREATE TABLE vegetables (Item VARCHAR(20), Quantity VARCHAR(2), Price VARCHAR (5), Required DATE);

As you can see above i have limited Item, Quantity and Price to data type VARCHAR and set Required as data type DATE. Furthermore you can see i have limited the amount of characters by specifying it in the brackets. To find out more about what kind of data types you can use visit

Now if you do a show tables this should now show vegetables table: –


Now to see all the columns in your table: –

mysql> DESCRIBE vegetables;

Now that we have our table and columns created we can now add data to the columns, there are two ways to do this, and they are with either or both: –


To insert the data from a file you will need to create a text document like vegetables.txt and populate it with the data that you want to add to the table and columns: –

Tomato  1       40p     2012-01-26
Cucomber        44      100p    2012-02-15
Cabbage 4       20p     2012-01-01
Potatoe 15      76p     2012-03-18

As you can see above i have typed the data and saved it to a text file called vegetables.txt. Notice how each column is seperated by a tab, this helps to distinguish each column from another. The columns represents data that will cover the table’s columns of Item, Quantity, Price and Required.

Now to put this data information into the vegetables table and columns we will have to do the following: –

mysql> LOAD DATA LOCAL INFILE ‘/home/main/vegetables.txt’ INTO TABLE vegetables;

Now the otherway to insert data into your tables and columns is by adding data information one at a time, for example let’s say we want to add the following data into the vegetables table and columns: –

sprouts    6        23p          2012-05-29

To add the above data information to the vegetables table and columns we do: –

mysql> INSERT INTO vegetables
-> VALUES (‘sprouts’,’6′,’23p’,’2012-05-29′);

Now to make sure all of this data information has been added to the tables and its columns we need to select to view either a specific column like ITEM: –

mysql> SELECT item FROM vegetables;

Or we can view all of the data information that we have put in the table by using * : –

mysql> SELECT * FROM vegetables;

So lets say that you have done the above command and found that one record is incorrect, lets say you want the sprouts to be 25p, again there are two ways to make this amendment. You can clear the table and columns of any data information and then load in the corrected information as well as all of the other data again from the vegetables.txt file: –

mysql> DELETE FROM vegetables;
mysql> LOAD DATA LOCAL INFILE  ‘/home/main/vegetables.txt’ INTO TABLE vegetables;

Or you can update the data row for the sprouts by: –

mysql> UPDATE vegetables SET Price = ’25p’ WHERE Item = ‘sprouts’;

Now let’s say we want to get a whole row of data for item Cabbage, this is how we do it: –

mysql> SELECT * FROM vegetables WHERE Item = ‘Cabbage’;

Similarly if we want to query all 2012-01-26 data information in the Required Table Column: –

mysql> SELECT * FROM vegetables WHERE Required = ‘2012-01-26’;

If you want to see whole table columns then you can specify which ones you want to see, for example i have specified to see Item and Price: –

mysql> SELECT Item, Price FROM vegetables;

We can order by the price too: –

mysql> SELECT Item, Price FROM vegetables ORDER BY Price;

If you want to order by Price going the opposite way then just replace Price with ‘Price’

Just to recap…

CREATE DATABASE database_name;

USE database_name

CREATE TABLE table_name (data_type (number_of_characters), data_type2 (number_of_characters));

LOAD DATA LOCAL INFILE ‘location_of_data_to_be_inserted_from_text_file’ INTO TABLE table_name;

This should be enough for a basic understanding of how to create information in mysql. The next thing to do would be to display this data int a dynamic loading webpage so instead if going to the command line and typing commands to view specific data we can instead use a webpage to do the same stuff.

Getting Apache Accessible on a Home Network

I started my Apache Webserver version 2.4 up on my Centos version 5.7 server. I could access my webserver by typing or localhost in the web browser and it would respond with “it works!”. But when I tried to access the Webserver from another computer by typing the internal network ip address allocated to the Centos Server it would fail to load up the website file from Apache Webserver. After digging around and double checking I found there were 2 issues not letting me access the Apache Webserver from other local computers connected to the same network, they were: –

  1. A directive called “Require” (
  2. The System Firewall Setup

The directive “Require” was setup by default to not give access to anyone. I resolved this by going to the configuration file of httpd: –

prompt> cd /usr/local/apache2/conf/
prompt> vi httpd.conf

Once in httpd.conf I found the directive “Require” was set to “Require all denied”, I changed this to “Require all granted” and then saved the file. This allows users to get access to the Webserver.

Once the directive “Require” had been changed I configured the systems firewall to enable both incoming and outgoing http and https traffic to the Centos Server: –

prompt> system-config-firewall-tui

I then proceeded to the Cutomize Menu and scrolled down and hit return to select Secure HTTPS and WWW (HTTP) traffic to be enabled on the Centos Server.

Once I completed the above 2 actions I was able to access the Webserver from other local machines. Furthermore I used my Broadband Routers port forwarding feature to forward port 80 (this is the port Apache’s Webserver listens to by default) to the Centos Server which in turn lets Apache Webserver communicate on port 80 with the HTTP(S) requests to provide the remote public internet user with web content!

Apache’s Directives

I wanted to change the directory where my website tree begins from, i.e. /usr/local/apache2/htdocs/index.html (this is the same website that I used to acknowledge that the Apache webserve is working correctly). In past verions of Apache webserver the normal tree directory would have been in the directory  /var/www/index.html

I did a bit more research into how to go abouts doing this by looking into Apache’s httpd website. I found out that to change where my websites hireachy begins I will need to change a “directive” called “DocumentRoot” to the directory that I would want my website’s hireachly to begin at. So basically to conifgure certain aspects of Apache’s webserver I need to change the value of a option called a “directive”.

Here is how I changed my websites hierachy from /usr/local/apache2/htdocs to /var/www : –

I found the “directive” that I needed to change by looking at the following URL: –

I then went to the configuration file of  Apache (httpd.conf) and amended the value so that it now points to /var/www: –

prompt> cd /usr/local/apache2/conf/

prompt> vi httpd.conf

amended the httpd.conf so that it now read: –

DocumentRoot “/var/www”
<Directory “/var/www”>

I created the directory as it was not present and then put a index.html file in it: –

prompt> sudo mkdir /var/www/

prompt> cd /var/www/

prompt> cat > index.html # Hit return, this will now let you enter data that will populate the index.html file that you have just created, make sure to type/copy the below line starting from <html> into your terminal

<html><body><h1>This website’s hireachy is now from /var/www !</h1></body></html>

# once done press Control D on your keyboard

It looks like you need to restart the Apache webserver for the changes to take place: –

prompt> service httpd restart

As always make sure to test to make sure the changes have been made. In this instance I included text in the html file above to say that it is from the /var/www directory. So once I went into an internet browser and type local host or it showed me the changes I made were successfull


Get every new post delivered to your Inbox.