Tuesday, 18 June 2013

Kill all java process in linux

Problem: To kill all the running java process in linux
Solution : killall java

Wednesday, 15 May 2013

Gunzip a file on linux

Problem: To zip a file on linux we can use utility like gzip

Solutiongzip -c trace.txt > trace.gz
The above command will compress the file trace.txt

Taking TCP Dump on Linux

Problem: Some times we need to monitor data that is flowing between systems. We can use tcpdump utility to take dump of the data and analyze the data (trace) with tools like wireshark.

Solution
tcpdump -i <interface> -s 65535 -w <some-file> 

Example:  tcpdump -i eth0 -s 65535 -w trace.txt

Tuesday, 7 May 2013

Running jetty server as background process in linux

Problem: Some times we need to run jetty server as background process in linux so that when we close the terminal the server will not stop.

Solution: nohup utility can be used to run jetty server (java process) in background. Following command can be used.

#nohup java   -jar start.jar jetty.port=18080  &

In the above command we are running jetty server on port 18080 as back ground process.

Monday, 29 April 2013

Finding files with time stamp linux

Problem:  Find files should list time stamp along with file name.

Solution
find -name demo.jar -printf '%Tc %p\n'

The above command will search for "demo.jar" file in current working directory and list results along with time stamp

Monday, 22 April 2013

HTML Encoding of data in EXT Template

Problem: HTML Encoding of data in  EXT Template.
Solution:
Ext provided an attribute "htmlEncode" to support encoding.

Example:

var tpl = new Ext.XTemplate('<p>Name: {name:htmlEncode}</p>');

Tuesday, 5 February 2013

Changing Command Prompt in Linux

Problem: Changing Command Prompt in Linux.
Solution: By default when you logged into terminal. You will see prompt as "[root@mydesktop build]#" (i.e)
[user@hostname current-workingdir]#. If you want to change these prompt settings change the environment variable PS1

To know default value:
[root@mydesktop build]# echo $PS1
[\u@\h \W]\$
To change value:
[root@mydesktop build]#export PS1='[\u@dragon \W]\$'
[root@dragon build]#

The values are lost when terminal is closed. To persist values for ever update file "/root/.bashrc"
My Bash file:
[root@dragon ~]#cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
export PS1='[\u@dragon \W]\$'