Find the version of the Linux distribution installed in your system

This post is a note to myself since I have come across the need of verifying the version of the Linux distribution installed on my system several times till date.

Method 1:

The standard technique I have been using till date to check the version of the Linux OS installed on my system was to execute: cat /etc/issue.

If you are using a customized version of the Linux based OS, the file, /etc/issue will probably display a custom message based on the OS distribution.

Method 2:

If you know that the Linux OS installed in your system is a variant of RHEL or Fedora, say CentOS, the command, cat /etc/redhat-release will provide the human readable release name of the installed OS followed by the version and the code name of the release.

If you are using other variants of the Linux OS, there is a high probability that the execution of the command, cat /etc/*-release may provide you with the necessary details.

Method 3:

If you are using a recent version of Linux distribution, the command: lsb_release -i -r will display the Distribution name (-i) and the Release number (-r).

On a side-note, if you are just looking for the version of the kernel and gcc that were used to build the release: cat /proc/version will provide the details.


References:
1. http://serverfault.com/questions/89654/what-version-of-rhel-am-i-using
2. http://serverfault.com/questions/188037/how-do-i-determine-what-version-of-red-hat-enterprise-linux-my-server-is-running
3. http://www.cyberciti.biz/faq/find-linux-distribution-name-version-number/
4. http://unix.stackexchange.com/questions/124667/how-to-know-which-linux-and-which-version-i-am-using

How to save a file edited in VIM using superuser permission?

How many times have you edited a file just to find out that you need root credentials to save the changes?

In situations like these, a well known trick comes to your rescue.

# Use the below syntax while saving the file from within VIM.
:w !sudo tee % > /dev/null

The internals of the above VIM command has been beautifully explained by Nathan Long at http://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work.


References:

How to resize VIM if it occupies just a part of the terminal screen space?

Sometime, we come across an issue where VIM only occupies just part of the available terminal screen space. We usually encounter this issue when we ‘ssh‘ into a remote machine and run VIM. This is because the terminal reported wrong number of rows and columns to the VIM editor.

As a fix for this issue, execute the command: ‘resize‘ (without quotes) on the terminal prompt and rerun VIM.


Reference:

How to print absolute path of a file with ‘ls’?

Use the ‘-d’ option of the ‘ls’ command.

Example:

For just the directory: ls –d /var/log

For everything in the directory: ls –d /var/log/*

For recursive listing of everything in the directory: ls –d /var/log/*/*


References:

How to check for open ports in Ubuntu (in general – any Linux based operating system)?

There are multiple ways to check for open ports in Ubuntu or in general – any Linux based operating system. Let me describe two of the most commonly used methods (at least by myself) in this article.

Method 1: Using the ‘netstat’ command

We can utilize the ‘netstat’ command as illustrated below to check for open ports in Ubuntu or in general any Linux based operating system.

 

netstat –lp --inet

For example:

Continue reading “How to check for open ports in Ubuntu (in general – any Linux based operating system)?”

How to install Apache, MySQL, PHP and PhpMyAdmin in Linux Mint from command line?

I am a great fan of Linux Mint. It’s Ubuntu based. I have been using Linux Mint for the past three years. Recently, I migrated to the latest version – Linux Mint 9 codenamed ‘Isadora’.  The default installation of the desktop edition of Linux Mint 9 does not install Apache, MySQL and PHP. Therefore, I decided to write a post that would be useful for other fellow readers, users of Linux Mint 9 detailing how to install Apache, MySQL and PHP on Isadora.

The installation can be divided into multiple steps.

  1. Install the core packages – Apache2, MySQL and PHP.
  2. Test if the web server is up and running.
  3. Test if PHP is working.
  4. Install PhpMyAdmin.
  5. Test MySQL (via PhpMyAdmin).

Continue reading “How to install Apache, MySQL, PHP and PhpMyAdmin in Linux Mint from command line?”