Tutorials in ‘Linux’ Category

How to setup Apache HTTP and HTTPS virtual hosts

Virtual hosting is a way of hosting several servers on a single machine. This technique is widely used in shared web hosting, because it greatly reduces hosting costs, since multiple customers use one server.

There are three types of virtual hosting:

  • Name-based – when the virtual hosts is determined by its domain. A problem with this approach is that it is completely dependent on the DNS.
  • IP-based – when each site is differentiated via his IP. A natural complication is that this requires a different IP for each site.
  • Port-based – when each site is described with the same domain, but different port. Naturally, the problem that users don’t generally use ports arises. Additionally, some firewalls block uncommon ports.

Using Apache, we will setup two name-based virtual hosts – an HTTP one and an HTTPS one. Both will work on the standard ports 80 for HTTP and 443 for HTTPS. Naturally we will see how to set port-based hosts.

Note: This tutorial assumes standard file places and settings for Apache on CentOS.

Note: The goal of this tutorial is not to provide extensive knowledge on configuring virtual hosts, but to provide a general-purpose working configuration. For more find-tuned configurations refer to the Apache documentation on virtual hosts.

We assume that <domain> is the domain for our virtual host. In the httpd/conf.d directory (usually /etc/httpd/conf.d) create a file called <domain>.conf

Note: It is not necessary to call your file <domain>.conf, but it’s a sort of a convention and makes editing hosts easier. The file for the HTTP virtual host should contain:

# <domain> HTTP Virtual Host
<VirtualHost *:80>
    # General
    ServerAdmin <administrator_e_mail>
    DocumentRoot /var/www/html/<domain>
    ServerName www.<domain>
    ServerAlias <domain>
    # Logging
    ErrorLog logs/<domain>-error_log
    CustomLog logs/<domain>-access_log common

<administrator_e_mail> is the e-mail of the site administrator. After you set this file restart the HTTP Server daemon:

service httpd restart

To setup an HTTPS virtual host, again create the <domain>.conf file in the /httpd/conf.d. Again we assume <domain> is the domain-name:

# <domain> HTTPS Virtual Host
<VirtualHost *:443>
    # General
    ServerAdmin <administrator_e_mail>
    DocumentRoot /var/www/html/<domain>
    ServerName www.<domain>
    ServerAlias <domain>
    # Logging
    ErrorLog logs/<domain>-ssl_error_log
    TransferLog logs/<domain>-ssl_access_log
    CustomLog logs/<domain>-ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    LogLevel warn
    # SSL Engine
    SSLEngine on
    # SSL Protocol
    SSLProtocol all –SSLv2
    # SSL Cipher Suite
    # Server Certificate
    SSLCertificateFile <path_to_certificate>
    # Server Private Key
    SSLCertificateKeyFile <path_to_private_key>
    # SSL Engine Options
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    # SSL Protocol Adjusments
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown owngrade-1.0 force-response-1.0

Of course, after setting this, restart the HTTP daemon:

service httpd restart

It is easily noticeable, that you can setup port-based virtual hosts quite easy, by using the same domain, but different ports in the .conf file.

Naturally this tutorial is not exhaustive, as such tutorial will be pretty much equal to documentation (which you can find here).

VN:F [1.9.18_1163]
Rating: 7.0/10 (2 votes cast)

Tips on Symbolic link or symlink in Unix Linux

In this tutorial I have shared my experience with Unix soft links and hard links.I found them extremely useful and have seen its versatile usage in various project.

This UNIX command tutorial is in continuation of my earlier article Top 10 basic networking Commands in Unix and 10 examples of using find command in UNIX if you haven’t read already you may find some useful information based on my experience in Unix and Linux commands.

Though this UNIX command tutorial is dedicated to highlight Differences between soft link in UNIX and hard link in UNIX which is also a very popular UNIX command interview question, I am not able to resist myself by showing you the usage of soft link in UNIX, below are some of example of UNIX symlinks I have seen during my projects of involving UNIX soft links:

1) In our project our Java process picks latest version of package for executing, which is a UNIX soft link. So whenever we do a release we just need to update latest UNIX symlink which makes release seamless and rollback very easy which in tern increases stability and predictability of our Java application.

2) All our UNIX script takes the location as argument so they are agnostic about the absolute path of resources and these resources are provided them via UNIX soft links and environment variables. This feature of our scripts saves a lot of time whenever we need to do any migration which involves changing location of resources.

3) An important point about UNIX soft link is that they inherit the permission of the folder to which they are pointing out.

Now let” see what are differences between Soft Link and Hard Link in UNIX

Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

10 example of using find command in linux

Find is very versatile command in UNIX and I used it a lot in my day to day work. I believe having knowledge of find command in UNIX and understanding of its different usage will increase your productivity a lot in UNIX. If your works involve lots of searching stuff or if you are a java or C++ programmer and your code resides in UNIX, find can greatly help you to look for any word inside your source file in the absence of an IDE, find is the alternative way of searching things in UNIX. grep is another command which provides similar functionality like find but in my opinion find is much more powerful than grep in unix.

This article is in continuation of my earlier article Top 10 basic networking Commands in Unix and Top 10 most useful CVS command in Unix .

Here I am listing down some of the way I use find command regularly, I hope this would help some one who is new in UNIX and find command or any developer who has started working on UNIX environment. this list is by no means complete and just some of my favorites , if you have something to share please share via commenting.

1) Running the last executed find command in Unix:

This will repeat the last find command executed. It saves lot of time if you re searching for something and you need to execute same command again and again. In fact \"!\" can be used with any command to invoke previous run of that command.

2) Finding files which has been modified less than one day in Unix:

find . -mtime -1
This is my favorite while looking out some issue just to check which files have been modified recently which could be likely cause of issue, believe me it helps a lot and many a times gives you enough hint of any problem due to intended or unintended file change. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

Top 10 basic networking command in unix

These are most useful command in my list while working on Linux server , this enables you to quickly troubleshoot connection issues e..g whether other system is connected or not , whether other host is responding or not etc.

This commands are very handy for troubleshooting day by day networking issues, having this networking commands its not just save time but also improves productivity.

I work as a Java , FIX developer for trading application . Since working with FIX involves lots of networking activity I used these commands every day and it saves quite a lot of time while identifying FIX connection issues. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Recover your Hard Drive like a Pro, How to Make a Low Level Image and Recover From It

Your hard drive crashed? It is likely that your files are still there! The FIRST thing you should always do in this situation is make an image (a copy) of your Hard Drive. Making an image won\”t fix anything; it will simply make an exact copy of your disk, copying good as well as corrupt data. Damaged hard drives usually only get progressively worse the more they are used, so to cut your losses you need to make an image. You then will recover your data from a different computer, using the image, while leaving the damaged hard drive alone – protecting it from further damage.

This tutorial will help you image your hard drive and then create a virtual hard drive on another Windows machine, using your image. Inside the virtual hard drive you should be able to see your lost data. This tutorial requires an external hard drive and the following free software:

The Ultimate Boot CD (Scroll down to \"Mirror Sites\" and click the download icon next to \"ISO\". It does not matter which sponser you use.) P2 eXplorer Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Remote desktop to Windows server from Linux

Windows stations and users are about 80% in the world so we need to connect and work with Windows operating system on daily basis. For such purposes we need relatively often to open remote desktop sessions to a remote Windows server. In Linux operating system we have a lot of different graphical applications which enable us to create a secure connection to windows terminal server. Even though we have client applications as tsclient, tsclient2, krdc and several more all these realy on one basic program which makes these applications to work.

The application in question is rdesktop. We will not cover the installation of this program as this varies on the different Linux distributions. Basically on standard Arch Linux system the usage this tool offers looks like this Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Enable kernel logging

Kernel Logging is an instrument for tracking and logging specified behaviors of the kernel in Unix or Linux operating system. It may significantly enhance the availability of the operating system by providing detailed kernel trace information to enable a system administrator or other troubleshooter to diagnose and eventually fix the root cause of a system problem without the need of a reboot of the system or performing long and time-consuming actions to reproduce the problem. This is possible because, working in the background, while the system is running, Kernel logging collects and stores messages aboutcertain events that have taken place. The contents of the log are available to you at any time.

Kernel logging is usually enabled by default in may Linux kernel based distributions, however, generally such messages are directed to the standard output of the operating system. In other words they go to the screen.

For the purposes of this tutorial we have used Redhat Enterprise Linux 4 update 4 to demonstrate how you can enable kernel logging and direct the output to a file.

The first step is to setup the syslog to collect kernel messages to a file.

The default config file is syslog is /etc/syslog.conf. In that file you should add the following line Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 3.1/10 (15 votes cast)

SSH tips and tricks. Dead or unresponsive ssh session

Even that I\”m a long experienced Linux user and administrator I have never used the ssh escape sequences that Linux provides. That, however, has changed in the last few weeks and I find it very useful for my everyday activities under ssh terminal.

In one of our previous tutorials I have demonstrated you how to make your ssh client send keep alive signals to the remote system. Even that this is a great tutorial and of course a great technique to avoid the moment when your ssh session becomes unresponsive just because it was opened a long time ago, ssh session keeps dying from time to time. In the past the way i was handling such cases was to kill the pid of my ssh session Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 9.0/10 (4 votes cast)

Gnome Keyboard Indicator with Country Flags

In this tutorial we will give you step by step instructions go to []show country flags in Gnome Keyboard Indicator.

1. If you do not have the got a language indicator attached to your panel, right click on the desired panel and select Add to Panel, find Keyboard Indicator near the bottom of the pop up dialogue, highlight it and click Add, then Close. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)

Argument list too long workarounds

If you have used Linux or Unix based systems you most likely have seen the infamous Argument list too long error message at least one time in your life, In our tutorial I will demonstrate you how to work around this message.

The Argument list too long error occurs anytime a linux user passes too many arguments to a single command. In the name of te tutorial I have used rm command as an example but the same problem applies for all regular system commands (ls *, cp *, rm *, etc…). This tutorial will focus on identifying few workaround solutions to this problem, each method using varying degrees of complexity to solve different potential problems. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)