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.
The standard technique I have been using till date to check the version of the Linux OS installed on my system was to execute:
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.
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.
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 (
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.
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.
# To set a hostname of a machine temporarily:
sudo hostname # E.g. sudo hostname ubuntu
# To set a permanent hostname (i.e. the hostname persists on reboot),
# update the /etc/hostname file.
sudo echo "" > /etc/hostname
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.
Use the ‘
-d’ option of the ‘
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/*/*
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
Continue reading “How to check for open ports in Ubuntu (in general – any Linux based operating system)?”
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.
Install the core packages – Apache2, MySQL and PHP.
Test if the web server is up and running.
Test if PHP is working.
Test MySQL (via PhpMyAdmin).
Continue reading “How to install Apache, MySQL, PHP and PhpMyAdmin in Linux Mint from command line?”