Tuesday, August 3, 2010

Some Useful Linux commands while deploying...


While deploying any WAR in tomcat on Linux platform, most problem we have faced is Linux terminal commands. In all industries you will mostly have a Linux server for test server,staging server etc...So most of the times developers need to test the code locally and then deploy it in centralized test OR development server where other can access and test it.

The steps will be same for all programmers. We get an email from so called IT people with deployment instruction having IP, username ,password (Which is always weird and we always copy paste it :)) etc... We Linux into the server using Putty or some other terminal client. But most of windows developers will face problem here. So some commands which are very easy to remember are,

- cd (Same as windows)
- pwd (Shows current working dir)
- ./ (this folowing with script filename, will execute the script. You can also use 'su')
- ps ax (Shows running process details, with process ID. like windows task manager shows.)
- grep hi (Finds the string 'hi')
- kill -9 567 (Kills process with ID 567)

Now in Linux if you have many servers running and you want to stop only specific one then you can use following combination,
- ps ax|grep projDir (This will show the process having projDir in sys variable.)

After that we can kill that process easily.

Before running startup.sh you must have set variable for JAVA_HOME, so that tomcat can find the java env.

There are other commands which are for changing file permissions (Read only, executable etc...) but will post it later.

-- Update By Kunal --
- scp sourcepath user@destserverhost:destpath (Secure copy of file from one linux server to another)

Example

scp /root/example.html root@66.235.111.88:/home/example

2 Comments:

Sandy said...

This is an excellent list, comes very handy. Hope it grows in future :)

Krunal said...

- Secure copy of file from one linux server to another

Syntax
scp sourcepath user@destserverhost:destpath

Example

scp /root/example.html root@66.235.111.88:/home/example