How to remove ^M characters at the end of lines in Vi from files in Linux?

Files created in windows when moved to linux will have ^M character at the end of lines when you open the files in Vi editor.

To remove the strange characters open the file in Vi editor and type


Continue Reading…

How to determine the file system type in Linux?

Linux supports many file system types like Ext2, Ext3, Ext4, NFS, FAT16, FAT32, NTFS etc. To find out what type of file systems are mounted in your system, issue the command

$ df -T

Output from the command

Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda1     ext4    94088076   9090252  80218356  11% /
udev      devtmpfs     1023536         4   1023532   1% /dev

How to find the port used by mysql?

List the listening ports and check if mysql is listed on it.

$ netstat -tln | grep mysql

If you cannot find the port number for mysql view my.cnf file to see if you can find the port number. If you see a line “skip-networking” try commenting out the line and then restart mysql daemon.

$ vi /etc/my.cnf

[mysqld] set-variable=local-infile=0
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).

[mysql.server] user=mysql

[mysqld_safe] log-error=/var/log/mysqld.log

$ service mysqld restart

How to setup Apache Tomcat, Java on CentOS?

Below set of steps involve setting up Tomcat 6 on CentOS 5 with Java 1.6

Download Apache Tomcat

$ wget

Go to opt/ folder and extract Tomcat

$ cd /opt

$ tar -xzf apache-tomcat-6.0.36.tar.gz

Create a tomcat user

$ useradd -d /opt/apache-tomcat-6.0.36/ tomcatuser

Change user permission on tomcat folder

$ chown -R tomcatuser:tomcatuser apache-tomcat-6.0.36
Continue Reading…

How to install java 6 on CentOS 5 and remove other JDK, JRE version?

At the time of writing this article Java 6 (update 37) was available at

First set up a folder where you want to install java

$ cd /opt

$ wget

$ chmod +x jdk-6u37-linux-x64-rpm.bin

$ ./jdk-6u37-linux-x64-rpm.bin
Continue Reading…

How to check, remove JRE, JDK, OPENJDK installation?

To check the current installation of java

$ rpm -qa | grep jre

$ rpm -qa | grep jdk

$ rpm -qa | grep openjdk

To remove the java installs

$ yum erase jre jdk openjdk

How to install and setup Fail2ban on CentOS?

Fail2ban is a software used to ban IP’s which shows strange behavior. It can be configured to reject IP’s for a certain amount of time.

To install Fail2ban we need to download the application from the source. Login as the root user and go to /opt

$ cd /opt

$ wget

Next unzip the downloaded file

$ tar -xf fail2ban-0.8.4.tar.bz2

$ cd fail2ban-0.8.4
Continue Reading…

Java Tomcat – SEVERE: Catalina.stop: Connection refused

This error pops up when you try to stop the Tomcat server when the server has not started. If you restart the Tomcat server, the error vanishes.

Java: non-static method cannot be referenced from a static context

Main is a static code block and to call a method within the same class you need to declare the other method also as static if you would want to execute the method during run time without instantiating it as an object.

Static methods are class methods and the methods without static keyword in them are instance methods.

Java: Buffered Reader Vs. Scanner

Buffered Reader
– Buffered reader reads text from a character input stream and buffers those characters
– Buffered reader has a buffer size of 8 KB
– Buffered reader is synchronized and can be safely called from multiple threads
– To parse for primitive data types additional functions needs to be called

– Scanner breaks down input into tokens and translates individual tokens according to their data type
– Scanner has a buffer size of 1KB
– Scanner is not synchronized
– Scanner can parse for primitive types and strings using regular expressions


Kurinchi Calendar
September 2018
« Oct