Reference : http://shaanob.blogspot.com/2010/06/working-with-postgres-and-tomcat-in.html
Working with postgres and tomcat in ubuntu
1. postgres: postgres by default resides in the port 5432 and unless and until you have modified that, the command remains the same everywhere. so open the terminal and use the following command
sudo /etc/init.d/postgresql-8.4 start
note: the version 8.4 might not be the version that you installed. so use the version number. and first try without giving sudo. if an error "permission denied" comes up, then use sudo. sodu command is to upgrade yourself to the root user or admin for that operation alone. for stopping postgres just replace start with stop.
2. tomcat: for tomcat, usually the folder reside in the usr/local folder if u install through the synoptic package manager, but i usually download the source from tomcat and then put it in my convenient folder. this is because i ve to either write a shell script or go to the source folder to execute commands. So lets to execute it by the folder way. i assume its in /home in a folder called tomcat6.
so for starting this is the following command
sudo /home/tomcat6/bin/startup.sh
and for shutdown,
sudo /home/tomcat6/bin/shutdown.sh
so you have to basically go into the bin folder of tomcat and run the startup and the shutdown script file