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]\$'


Monday, 4 February 2013

set mysql root user password

Problem: Set password for mysql root user
Solution: The default installation of mysql on CentOS doesnt set password for root user. To set password for root user type below command.



 [root@dragon ~]# mysqladmin -u root password root 

The password for the root user we are setting here is root

Thursday, 29 November 2012

Updating artifact in remote maven repository

Problem: I have to updated "liferay-portal-6.0.6.zip" artifact in remote maven repository.

Solution:

  1. Provide remote repository access setting in settings.xml for example
    1. Edit file C:\Users\dragonadmin\.m2\settings.xml
    2. Provide server info

    3. 
                        
                            remote-repository
                            admin
                            *****
                          
      
      
  2. Execute below command on terminal to update the artifcat.

    1.  
      mvn deploy:deploy-file -DgroupId=com.liferay -DartifactId=liferay-portal -Dversion=6.0.6 -Dpackaging=zip -Dfile=C:/work/liferay-portal-6.0.6.zip  -Durl=http://dragon.home.com:8081/artifactory/maven-proxy -DrepositoryId=remote-repository
      

Thursday, 1 November 2012

Free ports in Linux

Problem: Want to find free ports in Linux. 
Solution:  You can use  nc (or netcat) utility to do port scanning and find out free ports in the system.
Example:
Below command list ports that are binded from 1-10000

 
[root@dragon ~]# nc -z localhost 1-10000
Connection to localhost 22 port [tcp/ssh] succeeded!
Connection to localhost 25 port [tcp/smtp] succeeded!
Connection to localhost 111 port [tcp/sunrpc] succeeded!
Connection to localhost 631 port [tcp/ipp] succeeded!
Connection to localhost 925 port [tcp/*] succeeded!
Connection to localhost 2207 port [tcp/*] succeeded!
Connection to localhost 2208 port [tcp/*] succeeded!
Connection to localhost 4105 port [tcp/*] succeeded!
Connection to localhost 4728 port [tcp/*] succeeded!
Connection to localhost 5222 port [tcp/xmpp-client] succeeded!
Connection to localhost 5229 port [tcp/*] succeeded!
Connection to localhost 5269 port [tcp/xmpp-server] succeeded!
Connection to localhost 7005 port [tcp/afs3-volser] succeeded!
Connection to localhost 7070 port [tcp/arcp] succeeded!
Connection to localhost 7080 port [tcp/*] succeeded!
Connection to localhost 7777 port [tcp/cbt] succeeded!
Connection to localhost 8005 port [tcp/*] succeeded!
Connection to localhost 8009 port [tcp/*] succeeded!
Connection to localhost 8010 port [tcp/*] succeeded!
Connection to localhost 8080 port [tcp/webcache] succeeded!
Connection to localhost 8222 port [tcp/*] succeeded!
Connection to localhost 8223 port [tcp/*] succeeded!
Connection to localhost 8224 port [tcp/*] succeeded!
Connection to localhost 8225 port [tcp/*] succeeded!
Connection to localhost 9005 port [tcp/*] succeeded!
Connection to localhost 9009 port [tcp/pichat] succeeded!
Connection to localhost 9080 port [tcp/glrpc] succeeded!
Connection to localhost 9090 port [tcp/websm] succeeded!