Starting tomcat in debug mode – Linux

To start tomcat in debug mode, you need to set JPDA_TRANSPORT=dt_socket and JPDA_ADDRESS=9000 environment variable. To set these variable for a session only, open command prompt and run following commands

export CATALINA_HOME=/home/xyz/opt/tomcat
export JPDA_TRANSPORT=dt_socket
export JPDA_ADDRESS=9000

now start tomcat using following command

$ %CATALINA_HOME%/bin/catalina.sh jpda start

Setting this variable in your personal ~/.bashrc file has the advantage that it will always be set (for you, as a user) each time you log in or reboot the system. To do so, open ~/.bashrc in a text editor (or create the file if it doesn’t already exist) and insert the following line anywhere in the file

export CATALINA_HOME=/home/xyz/opt/tomcat
export JPDA_TRANSPORT=dt_socket
export JPDA_ADDRESS=9000

Save and close .bashrc.
You must logout and login again to make your change take effect. or source your .bashrc file to make your change take effect for the current session

$ source ~/.bashrc

Running a process in background/foreground in linux

Run process in background
To run a command in background, you can use following command at command prompt

$ command &

Above command will make your process run in background. You need to make sure that process is finished before logging off. A process run by above command will be terminated as soon as you logout.
If you want to run a command in background even after you logout then you can use following command

$ nohup command &

nohup Run a command immune to hang ups, with output to a non-tty.
This command will run your process in background even if you logs out.

Making current process to run in background
You can make current process as a background process by issuing following commands.

$ [ctrl] + z
$ bg

You need to remember that the process is running in background, if you logs out then process will be terminated. You can disown to avoid killing the process after you close the terminal.

$ [ctrl] + z
$ bg
$ disown

Execute following command to run any process in background

$ bg process_id

You can find process id by issues ps command. It displays the list of currently running process and their process ids. Use ps aux to see all the process currently running on your system including from other users. Use top to get updated list of all the processes running currently.

Run a process in foreground

$ fg process_id

rpm command – can’t create transaction lock

In case if you are getting error on running rpm command e.g.

$ rpm -e jdk-wrapper-1.5.0_15-1.gdg.noarch
error: can't create transaction lock on /var/lib/rpm/__db.000

Installing eclipse in ubuntu/linux

Download eclipse from http://www.eclipse.org/downloads/
Make an opt directory in user’s home directory

$ mkdir ~/opt

Go to the directory where you have downloaded eclipse

$ tar -xvf eclipse-SDK-3.4.1-linux-gtk.tar.gz && mv eclipse ~/opt

Make a bin folder in user’s home directory

$ mkdir ~/bin

Next create an executable for Eclipe at ~/bin/eclipse

$ vi ~/bin/eclipse

Add the following lines in this file

export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export ECLIPSE_HOME="$HOME/opt/eclipse"
$ECLIPSE_HOME/eclipse $*

Finally make script executable

$ chmod +x ~/bin/eclipse

You can now execute that file to start up Eclipse.

<< Back to Setting up j2ee developer environment ...

Installing JDK in ubuntu/linux

To install jdk6.0 type the following command in terminal window

$ sudo apt-get install sun-java6-jdk

Provide password for root. It will show you agreement. Select and wait for installation to be completed.
We should set JAVA_HOME environment variable after successful installation of jdk.

$ vi ~/.bashrc

Insert following line in above file

export JAVA_HOME=/usr/lib/jvm/java-6-sun

<< Back to Setting up j2ee developer environment ...

ifconfig command : Manage network configuration in linux

The most frequent use of ifconfig command is setting an interface’s IP address and netmask, and disabling or enabling a interface.
To see IP address of the machine, open terminal and type ifconfig
It’ll list all the interfaces connected to the device e.g.

root@ubuntu:~$ ifconfig
eth0    Link encap:Ethernet  HWaddr 00:1c:23:a4:ed:b0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:160524 errors:0 dropped:0 overruns:0 frame:0
          TX packets:59261 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40668433 (40.6 MB)  TX bytes:14468340 (14.4 MB)
          Interrupt:17 

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:21240 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21240 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3990382 (3.9 MB)  TX bytes:3990382 (3.9 MB)

To view a particular interface, provide interface name after ifconfig command.

root@ubuntu:~$ ifconfig eth0
eth0    Link encap:Ethernet  HWaddr 00:1c:23:a4:ed:b0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:160524 errors:0 dropped:0 overruns:0 frame:0
          TX packets:59261 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40668433 (40.6 MB)  TX bytes:14468340 (14.4 MB)
          Interrupt:17

here are few more frequent usages of ifconfig
ifconfig eth0 down
This flag causes eth0 interface to be shut down.
ifconfig eth0 up
If interface eth0 is in the down state then by setting this flag will make eth0 interface active.

ifconfig eth0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.20
Assign eth0 with the above values for IP, netmask and broadcast address.

Backup of mysql database

Use the following command to get backup of complete mysql database.

shell> mysqldump -u [username] -p[password] –all-databases > [backupfile.sql]
–if you want to take backup of selective database then u need to specify database name like
shell> mysqldump -u [username] -p[password] –databases [databasename] > [backupfile.sql]

Syntax in above commands are explained below
username – User name of mysql database
password – Password of mysql database
databasename – Name of the database you want to take backup
backupfile – Name of the backup file
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

Starting httpd in linux

To start httpd, you need to type following commands

<br>
[root@momo ~]# cd /etc/rc.d/init.d/<br>
[root@momo ~]# ./httpd start<br>

To test is httpd service is running, type following command

<br>
[root@momo ~]# ps -ef|grep httpd<br>

and this will give you results like

<br>
apache    2862  2860  0 Aug18 ?        00:00:00 /usr/sbin/httpd<br>
apache    2863  2860  0 Aug18 ?        00:00:00 /usr/sbin/httpd<br>
apache    2864  2860  0 Aug18 ?        00:00:00 /usr/sbin/httpd<br>

To check if your httpd is installed in the system, type below command in the console

<br>
[root@momo ~]# httpd -version<br>

Technology