Useful GNU Linux commands

During the past week I spend most of my time and effort on installing and configuring Ubuntu Server 10.04.3 and required applications, so following are some of the useful commands I came across.

Manual Partitioning

As a practice, when installing GNU Linux I partition the harddisk as follows by selecting the option of manual partition.

  • / – Root partition
  • /boot – Boot partition, that keep the grub loader, especially important when multiple operating systems are installed.
  • /home – Home partitions where the user data will be stored
  • swap – Swap partitions, recommends to allocate double the size of RAM attached to the machine.

Once the partitioning is completed the OS installation will take few minutes to complete. Next step will be to configure the server to establish a connection to the Internet via the local network.

Network Configuration – Static IP approach

Let us see the steps involve in assigning a static IP and the DNS information.

  • Check whether the network card is properly working and the cable is properly connected as follows:
    $ sudo mii-tool eth0
    should give the details of the network card instead of no link message.
  • Backup the existing interfaces configuration file as follows:
    $ sudo cp /etc/network/interfaces /etc/network/interfaces.bk
    and open the interfaces file as following
    $ sudo vim /etc/network/interfaces
  • Replace the values for address, netmask, gateway, and broadcast with values specific to your desired IP address and network.
    # The loopback network interface
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.1.40
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

  • Setting the IP’s for the DNS Server(s), backup the resolv.conf as follows:
    $ sudo cp /etc/resolv.conf /etc/resolv.conf.bk
    and update the nameservers as follows:
    $ sudo vim /etc/resolv.conf
    nameserver 192.168.78.174
    nameserver 192.168.78.174
  • Next, restart the network interfaces as follows:
    $ sudo /etc/init.d/networking restart
  • Finally, test the configuration first by pinging to the Gateway IP and then to another external IP or site like www.google.com
    $ ping 192.168.1.1
    PING 192.168.1.40 (192.168.1.40) 56(84) bytes of data.
    64 bytes from 192.168.1.40: icmp_seq=1 ttl=64 time=0.051 ms
    64 bytes from 192.168.1.40: icmp_seq=2 ttl=64 time=0.061 ms
    64 bytes from 192.168.1.40: icmp_seq=3 ttl=64 time=0.068 ms

Mount/unmount a filesystem – External hard disk with a ntfs filesystem

  • Find the device name (eg: /dev/sdb1) required to mount using the following command.
    $ sudo fdisk -l
  • Create a mount point and mount the external hard disk as follows:
    $ sudo mkdir /media/external_hard
    $ sudo mount -t ntfs-3g /dev/sdb1 /media/external_hard
  • Unmount the hard disk as follows:
    $ sudo umount /media/external_hard

Subversion

Two years have passed

Looking back into the past two years I spend in the industry getting graduated with a B.Sc. in IT, it gave me a chance to experiment on what I learnt in the uni. The period that I spent in the university was so exciting and adventurous, where I got the chance to get involve with some interesting research projects, one project that contributed to the well being of the global community while another one had military involvement. I was so fortunate that during all those involvements I got the privileged to work under the reputed professionals in the industry.

Although the place I joined first didn’t worked out well but there was this one project that I got involved gave me the opportunity to learn and do what I was actually spending most of my free time during the university. The project was all about controlling the presentation layer of the Web Browser using CSS (theming more than 600 websites with 400 to 500 pages per site on top of Drupal CMS using Zen theme and Zenophile module). Initially I got an excellent insight into CSS and Drupal framework from Chris Craig, who spent a couple of weeks with our team. Every time the designers were coming up with crazy and elegant designs which we have to port them back into the newly created Drupal sites without failing to miss a single dot and even missing the slightest fraction of the layout of the components including IE 6, 7 and 8, which was a nightmare in the beginning. Within a month time I managed to release two conversion per week.

As a principal I always try to be honest and straight with what I know, but unfortunately it didn’t worked out well for me with my boss. He always tried to fool me and cheat me in many occasions. So after spending more than one year with them I decided that the time has come to say goodbye. So I took the decision to leave the place and gave them two months advance notice. Next stop was the place where I currently working. Initially the environment was somewhat similar to my previous place but since the entire team consists of energetic young blood, so because of that everybody had our own strengths and weakness where we fought each other over that. But the interesting part of it is that the project (which I’ll discuss about it in the future, but if things turned out well it will be a thing that we all can be proud of for all the hardship we went through) in front of everybody was way beyond our radar. Which I believe that was the reason behind all that. Fortunately our team was blessed with a futuristic and generous management so the things didn’t went bad, instead we got a new light to our team. With this project I’ll be able to explore into various technologies where I’ll never even be dream of, if not which will at least take me more than five years or so.

Google Analytic user action tracking inside Flash

Recently I got the chance get involve with the development of the site called I Call Mine. It is a Flash based interactive site that was dedicated for males, focusing on helping the medical practitioners in UK to getting an understanding of the terms used by males to call their big fella in general.

The site collects the user’s choice and displays it with respective to the region as a word cloud. In the meantime the client wanted to track the user’s interaction on the site through Google Analytics as well. In this effort we refer the method introduced by Evan Mullins to integrate the event tracking functionality of Google Analytics to the Flash application.

Additionally have to make sure to set the parameter of allowScriptAccess to always when embedding the Flash object to the Web page. You can find more information over here. I have to specially thank Anjana for his time and effort on this.

Once the event tracking code is in place you’ll be able to monitor the site’s user activity through Google Analytics page. As soon as you Sign-in to the account it shows the general statistics of the site on the Dashboard – refer the first image below. To monitor the activity of the event tracking navigates along the left side navigation to Content section. Once inside that you’ll get a section called Event Tracking which displays an in details view of the event tracking used inside the Flash application – please refer the second image below.

HTTP Compression

Sometime back in the office, we wanted to find ways to reduce the loading time of the the Web application we have been developed for the past year. During this process I came across several approaches and tools, some which discussed about best practices that should be followed even when we are developing a simple application while some provided solutions that can directly applied to the web server.

Today Internet has revolutionized our daily activities and the web site is playing a major part there. So it’s very important that the web page load as quickly as possible. In this effort I found that Yahoo has provided loads of valuable resources through tutorials, videos, tools(YSlow, Smush.it™, JSLint, YUI, etc…), etc… that greatly helps the web developers to improves their understanding about the basics that do matters most.

Another approach I came across is the HTTP Compression, which makes the content compressed at the web server and sent to the web client(browser) over the wire, which saves the bandwidth, increases the loading time, etc… Here the Web browser handles the decompression of the content before displaying it to the user. Currently almost all the modern Web browsers handles it without any problem, so it’s a safer and an effective approach to increase the performance of the Web application.

Following is an approach I found in the Ubuntu forum that helped me to enable the HTTP compression in the server which I had worked.

Virtual Hosting

Last month I got a chance to play with an Ubuntu Linux server to set up Virtual Hosting for couple of sites in the office. Most of the time this is achieved through cPanel interface, this server was not supported with GUI tools but I got the root access :-) .

Unfortunately I had only heard and read little about Virtual Hosting. So this was sort of a challenge for me. So first of all I did a bit of searching to get to know the basics of Virtual Hosting. With couple of hours effort I managed to figure out what should be done.

Following is the folder structure I created in the server to hold the site related resources. Sometimes I might have missed some of the important aspect, so strongly recommends you to refer here for a complete explanation.

/home/websites/yoursite.com/
                                                |
                                                |—- html
                                                |—- logs
                                                |—- etc

  • html – place all the resources required for the site.
  • logs – place the access log and error log files.
  • etc – place other resources that are not directly required for the site but you feel like useful for future activities.

Once above is completed next step is to update the apache server about the new Virtual Host. Following block illustrates the necessary configuration for the new Virtual Host. Opens up your favorite text editor and place the below content block and replace the ‘yoursite.com‘ with the sites actual name. Save the file as yoursite.com in the following path: /etc/apache2/sites-available/ and create a symbolic link to /etc/apache2/sites-enabled/.

How to

  • Opens the terminal window
  • Creates a new file having a name like ‘yoursite.com‘ (replace this with your actual site details) using vim editor: sudo vim /etc/apache2/sites-available/yoursite.com
  • Enter into insert mode by pressing i key on your keyboard and place the below code block and replace respective location to reflect to your site’s settings.
  • Next click Esc key on your keyboard and type :wq
  • Finally create a symbolic link to /etc/apache2/sites-enabled/ using following command: ln -s /etc/apache2/sites-available/yoursite.com /etc/apache2/sites-enabled/yoursite.com

ServerAdmin webmaster@localhost

DocumentRoot /home/websites/yoursite.com/html/
ServerName www.yoursite.com
ServerAlias yoursite.com

Options Indexes FollowSymLinks
DirectoryIndex index.html, index.php

ErrorLog /home/websites/yoursite.com/logs/error.log

# Possible values include: debug, info, notice, warn, error, crit,alert, emerg.

LogLevel warn

CustomLog /home/websites/yoursite.com/logs/access.log combined
ServerSignature On

« Older entries

Follow

Get every new post delivered to your Inbox.