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

Advertisements

How to fix the Tomcat 7 private instance and Eclipse integration error in Ubuntu

The first step as part of my journey in learning Spring MVC was to create a private instance of Tomcat 7. The procedure I had followed is documented as part of my earlier post: How to setup multiple instances of Tomcat 7 in Ubuntu.

The next step was to setup Eclipse to recognize the Tomcat 7 private instance.

A new server instance can be registered in Eclipse using Window -> preferences -> Server -> Runtime Environments menu.

But, when I try add the private Tomcat 7 instance, Eclipse reports that it could not identify the version of the Tomcat and refuses to register the instance.

Following the suggestions by David Edwards at askubuntu.com for a problem not directly linked to my problem, solved the Eclipse-Tomcat7-private-instance-integration issue.

The solution suggested by David Edwards was to create a link for the lib and bootstrap.jar library in the private instance folder.

Due to missing fix for the bug-297675 in the tomcat7-user package, the tomcat7-instance-create script fails to setup everything as required by Eclipse when executed.

The part of the solution that I followed can be divided into two steps.

Step 1: Create a link to the lib folder and the bootstrap.jar file located at /usr/share/tomcat7 in the tomcat7 private instance directory.

ln -s /usr/share/tomcat7/lib ~/Workspace/github/springapp/tomcat//lib
ln -s /usr/share/tomcat7/bin/bootstrap.jar ~/Workspace/github/springapp/tomcat/bin/bootstrap.jar

In addition, I also had to create a link to /usr/share/tomcat7/bin/tomcat-juli.jar.

ln -s /usr/share/tomcat7/bin/tomcat-juli.jar ~/Workspace/github/springapp/tomcat/bin/tomcat-juli.jar

Note: ~/Workspace/github/springapp/tomcat is my Tomcat 7 private instance folder created using tomcat7-intance-create script.

Step 2: Either download the catalina.policy file from code repository or from within the general Tomcat 7 instance configuration folder. For instance:

# If you opt for downloading the file - replace 'precise' with the right name of your Ubuntu release.
curl http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/tomcat7/precise/download/head:/catalina.policy-20110521092527-dk8tcyjy21h8eu9h-1652/catalina.policy > ~/Workspace/github/springapp/tomcat/conf/catalina.policy

Note: Make sure that you are downloading the latest version of http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/tomcat7/precise/view/head:/conf/catalina.policy file.

Eclipse should be able to recognize the version of Tomcat without issues.

Meanwhile, shutdown and restart the private instance using the commands:

settipalli@settipalli-ubuntu:~/Workspace/github/springapp/tomcat$ ./bin/shutdown.sh

# Followed by:
settipalli@settipalli-ubuntu:~/Workspace/github/springapp/tomcat$ ./bin/startup.sh

References:
1.How to setup multiple instances of Tomcat 7 in Ubuntu
2.Unknown version of Tomcat was specified with tomcat-7.0.42
3.Tomcat and Eclipse Integration Error : “Unknown version of Tomcat was specified.”
4.Cannot start tomcat after installing a private instance
5.Tomcat 7 and Eclipse integration getting error
6.Configure TOMCAT in Eclipse
7.Eclipse Community Forums – Can’t add a new Tomcat 7 Server
8.Eclipse 4.2 (Juno) ‘Cannot create a server using the selected type’ in Tomcat 7
9.Eclipse can’t find catalina.policy and bootstrap.jar where it expects them
10.Man page of tomcat7-instance-create

How to fix blank screen issue while attempting to edit WordPress blog posts in distraction free writing mode in Ubuntu?

I like writing, though I write occasionally. WordPress.com has been my platform of choice for several years now. I used to use the Windows Live Writer to create and edit my blog posts in Windows. It is excellent editor by all angles. When using Ubuntu, I stick with the web-based text editor on WordPress.com.

Since the launch of Markdown support for WordPress.com web based editor(http://en.support.wordpress.com/markdown/), my dependency on the web-based editor increased multifold.

Recently, I was plagued by the ‘blank screen’ problem whenever I used to switch to the ‘distraction free mode’ while editing text from within the Text Editor on the Chrome browser.

Meanwhile, I encountered the same problem when launching https://web.whatsapp.com to use the WhatsApp web client from within the Chrome browser. The symptoms of the problem seemed alike. And the solution also worked.

The solution was to launch the Chrome browser with hardware based rendering disabled using the command:

settipalli@settipalli-ubuntu:~$ google-chrome --disable-gpu

The other blog post also provides details on creating a desktop shortcut for Chrome browser with GPU disabled.


References:
1. How to fix the blank screen problem while launching WhatsApp web client from Google Chrome installed in Ubuntu
2. WordPress.com
3. Ubuntu 12.04.5 LTS (Precise Pangolin)
4. WordPress.com – Markdown
5. Write (More) Effortlessly With Markdown
6. WordPress.com – Writing and Editing – Editor
7. Markdown – Wikipedia
8. Download Windows Live Writer

How to fix the blank screen problem while launching WhatsApp web client from Google Chrome installed in Ubuntu

I have Ubuntu 12.04.5 LTS version installed on my Compaq Presario A900. Its a widescreen laptop (actually, a desktop replacement) with 17 inch display. I love the large screen and the full sized keyboard. Its such a pleasure to see Ubuntu run smoothly on this laptop.

Recently, WhatsApp launched their web-client with a limitation that it can only run on the Chrome web browser.

When I launched https://web.whatsapp.com on the Chrome browser, everything seemed fine. Scanned the QR code and found that my display went blank. No response for any keystrokes, mouse movements. The only way to recover was to put the system to sleep and wake-up. Upon wake up, Unity would crash and unity-reset does not help. The only option was to issue a graceful reboot from the terminal (Ctrl-Alt-F1). The issue was reproducible consistently.

Initially, I felt this could be a display driver problem. Since the laptop contains an Intel Integrated Graphics Adapter, I verified if there are any new drivers listed on the HP website. Found everything was up to date with respect to Graphics adapter and related drivers.

The second step was to Google for a solution. There are numerous people who have reported ‘Blank Screen issue on Ubuntu 12.04 LTS’. Most of them were related to Screen Saver and some of them with respect to XOrg settings. None of the solutions helped.

Finally, with a hunch, I started reading about Google Chrome features and the steps to be followed to enable/disable experimental features. As part of this investigation, I came across an option to disable ‘GPU Hardware Rendering’. The option was --disable-gpu. This option turned off the hardware rending facility in the browser and restricted it to use ‘Software Renderers’. The quality of the output when hardware rendering is used is usually superior, but in this case, I had to stick with software renderers.

settipalli@settipalli-ubuntu:~$ google-chrome --disable-gpu

Running Chrome with GPU rendering disabled solved the mystery behind the blank screen. I was able to launch https://web.whatsapp.com perfectly without issues.

I decided to create a desktop shortcut for the Chrome with GPU disable switch turned on such that whenever I would like to use the WhatsApp web client, I do not accidentally start the browser with hardware rendering enabled and be greeted with a blank screen.

The first step was to copy the exisitng google-chrome.desktop script located within the /usr/share/applications folder and name it, say, google-chrome-gpu-disabled.desktop. The contents of the script are listed below:

[Desktop Entry]
Version=1.0
Name=Google Chrome - GPU Disabled
# Gnome and KDE 3 uses Comment.
Comment=Access the Internet
Exec=/usr/bin/google-chrome-stable --disable-gpu %U
Terminal=false
Icon=google-chrome
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;image/webp;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;
X-Ayatana-Desktop-Shortcuts=NewWindow;NewIncognito

[NewWindow Shortcut Group]
Name=New Window
Exec=/usr/bin/google-chrome-stable --disable-gpu 
TargetEnvironment=Unity

[NewIncognito Shortcut Group]
Name=New Incognito Window
Exec=/usr/bin/google-chrome-stable --incognito --disable-gpu 
TargetEnvironment=Unity

Now, whenever I search Chrome from within the Search bar in the Unity-Dashboard, I could see two Chrome icons, one with the GPU support, other without the GPU disabled.


References:
1. WhatsApp web-client
2. Ubuntu 12.04.5 LTS (Precise Pangolin)
3. Compaq Presario A900 Notebook PC
4. WhatsApp Blog – WhatsApp Web
5. Chrome Browser – Google

How to setup multiple instances of Tomcat 7 in Ubuntu

I was trying to learn Spring MVC and was interested to setup a dedicated instance of Apache Tomcat 7 for the pet project rather than using the single installed instance. I used a Ubuntu 12.04 LTS desktop edition while performing the below steps.

Using a dedicated instance rather than a general instance would allow me load custom libraies and not tamper with the settings and libraries utilized by the general instance of Tomcat 7.

Step 1: Install the tomcat7-user package.

sudo apt-get install tomcat7-user

Step 2: Setup a parent folder where you would like to store the instance specific configuration and libraries

mkdir $HOME/Workspace/github/springapp

I have specified a path specific to my project folder. You can choose any folder of your choice.

Step 3: Use the tomcat7-instance-create command to create and configure the Tomcat 7 instance folder at $HOME/Workspace/github/springapp/tomcat.

tomcat7-instance-create $HOME/Workspace/github/springapp/tomcat

# SYNOPSIS FOR REFERENCE
#       tomcat7-instance-create [OPTIONS] DIRECTORYNAME

The default port used by the instance would be 8080. If you would like have the new instance listen to a different port, use the -p switch. This is useful when you like to have both the general and the dedicated instance of Tomcat running simulataneously.

Similary, the -c switch allows us to specify a control port which can be used to send ‘Magic Words’ that cause Tomcat to trigger specific actions. For instance, the default magic word to gracefully shutdown Tomcat is SHUTDOWN and the default control port is 8005.

As an example, to have Tomcat listen on port 8085 with control port being 8010 and the Magic Word to shutdown Tomcat being TAKEYOURLOADOFF:

tomcat7-instance-create -p 8085 -c 8010 -w TAKEYOURLOADOFF $HOME/Workspace/github/springapp/tomcat

The output would be similar to:

You are about to create a Tomcat instance in directory '$HOME/Workspace/github/springapp/tomcat'
* New Tomcat instance created in $HOME/Workspace/github/springapp/tomcat
* You might want to edit default configuration in $HOME/Workspace/github/springapp/tomcat/conf
* Run $HOME/Workspace/github/springapp/tomcat/bin/startup.sh to start your Tomcat instance

Note: The variable $HOME would be replaced with the absolute path of the directory in your output.

To learn more about the options available for the tomcat7-instance-create command, please refer the man page:

[man tomcat7-instance-create][3]

Step 4: Start the new instance of Tomcat 7.

settipalli@settipalli-ubuntu:~/Workspace/github/springapp$ tomcat/bin/startup.sh
Using CATALINA_BASE:   $HOME/Workspace/github/springapp/tomcat
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: $HOME/Workspace/github/springapp/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Tomcat started

Step 5: To verify if the new instance of Tomcat has loaded successfully, navigate to ‘localhost:8085‘ in your web-browser. You would be greeted with an empty page. This is normal.

To confirm if Tomcat has started and is listening on the specific ports, execute the below command.

settipalli@settipalli-ubuntu:~/Workspace/github/springapp$ netstat -punta | grep java
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::8085                 :::*                    LISTEN      4862/java
tcp6       0      0 127.0.0.1:8010          :::*                    LISTEN      4862/java

To reconfirm if everthing is fine, look into the logs at: $HOME/Workspace/github/springapp/tomcat/logs/localhost_access_log..txt. The content should be similar to:

127.0.0.1 - - [30/Jan/2015:04:03:55 +0530] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [30/Jan/2015:04:03:56 +0530] "GET /favicon.ico HTTP/1.1" 404 -

Since we have not configured any web-apps to be servered by Tomcat, 404 response is valid.

Similary, review $HOME/Workspace/github/springapp/tomcat/logs/catalina.out for Tomcat startup messages.

To shutdown the instance, use the below command:

settipalli@settipalli-ubuntu:~/Workspace/github/springapp$ tomcat/bin/shutdown.sh

# Sample Output of the command
Using CATALINA_BASE:   /home/settipalli/Workspace/github/springapp/tomcat
Using CATALINA_HOME:   /usr/share/tomcat7
Using CATALINA_TMPDIR: /home/settipalli/Workspace/github/springapp/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Jan 30, 2015 4:11:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Jan 30, 2015 4:11:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Jan 30, 2015 4:11:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Jan 30, 2015 4:11:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Jan 30, 2015 4:11:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Jan 30, 2015 4:11:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/var/lib/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Tomcat stopped

References:
1. Add another instance of Tomcat, on Ubuntu
2. How to install Multiple instances of tomcat on a single ubuntu server
3. tomcat7-instance-create – Gists – GitHub
4. Ubuntu 12.04.5 LTS (Precise Pangolin)
5. Man page of tomcat7-instance-create

How to disable Unity animations in Ubuntu 14.04?

If you are running Ubuntu in VirtualBox or other virtualization platform, disabling all the animations improves the response of the OS to certain extent.

Starting with Ubuntu 12.10, MyUnity integration with the System Settings (as was the case in 12.04) has been removed. In 12.10 and above, which includes 13.04, 13.10 and 14.04, Compiz settings manager can be used to disable the required animations.

  • Step 1: Install Compiz Settings Manager12.
    sudo apt-get install compizconfig-settings-manager
  • Step 2: Disable Animations345
    • Start the application (from the Unity Dash)
    • Traverse to Unity plugin -> Experimental (tab)
    • Disable the animations as required.

References:

How did I improve the performance of my Ubuntu 12.04 system?

There are many web pages that outlines steps to be performed to increase the performance of your Ubuntu system. In this post, I would like to outline the steps that I have followed to increase the overall performance of the system. Most of the tweaks listed below were captured from the websites listed in the References section.

Disclaimer: If you do not know what you are doing, then it would be better to leave your working system as is. There is always a possiblity that you may destablize your system by modifying critical system settings. Please use caution when performing the below outlined steps. I have outlined the steps that I had performed; this by no means indicates that your system would perform better than it is. Use the below listed suggestions at your own risk.

  • Remove unwanted services using Boot-Up Manager (bum)1:
    • Install BUM: sudo apt-get install bum
    • Open BUM using: System -> Administration -> BootUP Manager or search for bum in Ubuntu Dash.
    • Or, execute sudo bum from comand line.
    • Disable the services that you do not prefer to auto-start as part of the system start-up sequence.
    • Refer to the reference links2 for more information on usuage of advanced usage of bum.
  • Remove few more services using sysv-rc-conf3:
    • sysv-rc-conf is a terminal GUI for managing services listed in /etc/rc[runlevel].d folder.
    • Install it using sudo apt-get install sysv-rc-conf
    • Start it using sudo sysv-rc-conf
    • Read about the tool using man sysv-rc-conf4
    • Use arrow keys to navigate and press space to enable or disable a service in a particular runlevel.
    • Press q to save and terminate the program.
    • Press r to revert the settings to the previous state (in case you have not yet saved the changes).
  • Disable/remove unused applications that run as ‘Background services’:
    • Use the solution mentioned at ‘Ask Ubuntu’5 to enable listing of services that auto-start along with Unity Desktop in the ‘Startup Applications’ menu. In summary execute the below commands (courtesy to Todd Partridge ‘Gen2ly’ – Ask Ubuntu)
      mkdir -p ~/.config/autostart # If not already created
      cd ~/.config/autostart
      cp /etc/xdg/autostart/*.desktop .
      sed -i "s/NoDisplay=true/NoDisplay=false/g" *.desktop
    • Click on the ‘Logout/Login’ icon on the ‘top-right’ corner of the Unity screen and select ‘Startup Applications control panel’ and disable the services that you do not use.
  • Remove the ‘indicator-messages’:
    • Its the ‘mail’ icon displayed on the ‘top-right’ corner of the Unity Desktop before the ‘Login/Logout’ and other menu items.
    • If you do not depend on it, you can execute the below commands to uninstall it.
      sudo apt-get autoremove indicator-messages
      sudo apt-get autoremove telepathy-indicator
  • Remove any left-over dependency packages that were not uninstalled when you uninstalled application:
    • Execute sudo apt-get autoremove
  • Use preload6:
    • If you prefer to let the system track the list of most frequently used applications and load them into the RAM before they are demanded, install ‘preload’ by executing sudo apt-get install preload.
    • Read How can I improve overall system performance? for some valuable input on preload.
  • Use BleachBit to unwanted files8:
    • As per the author, ‘BleachBit can be used to free cache, delete cookies, clear Internet history, shred temporary files and delete logs.
    • Install it using, sudo apt-get install bleachbit and run it by searching for the ‘BleachBit’ applition in the Unity Dash.
  • Adjust swappiness9:
    • Read the article – Ask Ubuntu – How do I configure swappiness? for some good insight into what swappiness is and how to configure it.
    • In summary, the swappiness value indicates how often the ‘swap’ file in the hard-disk is used.
    • By default, it may be set to 60 (in my system it was pre-set to 60). This implies that the kernel will swap the contents in the RAM to the disk when the RAM is about half full.
    • Check your the swappiness value set in your system using the command: cat /proc/sys/vm/swappiness
    • To change the value, open /etc/sysctl.conf (as root) and set/add the line, vm.swappiness = 10.
    • A value of 10 indicates that the swap file will only be used when the RAM is about 80% or 90% full.
  • Disable visual effects:
    • You can switch to a 2D desktop environment by installing: gnome-session-fallback using the command: sudo apt-get install gnome-session-fallback
    • You can also consider alternative desktop environments such as XFCE, LXDE etc. These are default in Xubuntu and Lubuntu respectively.

References: