Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Every time I need to start or stop Tomcat, I am navigating to:

 /Tomcat_Dir/bin

and once I am in the folder I enter:

./Startup.sh

And to stop the server, I navigate to the same directory and enter:

 ./Shutdown.sh

I was wondering if there was a way in Linux to alias the above described process, so that from any location in the filesystem, I can simply type in something like

StartTomcat or StopTomcat to perform the Startup and Shutdown of the web-server?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

You don't even need to navigate to these directories. Just use the full paths instead:

/Tomcat_Dir/bin/Startup.sh
/Tomcat_Dir/bin/Shutdown.sh

With those, you can create an alias, as you said:

alias StartTomcat='/Tomcat_Dir/bin/Startup.sh'
alias StopTomcat='/Tomcat_Dir/bin/Shutdown.sh'

Add these lines to your ~/.bash_profile, ~/.profile, or ~/.bashrc (whichever you're using – what is the difference?), restart the shell, and you're done.

share|improve this answer
add comment

I know of three easy options -

1) You can add the /Tomcat_Dir/bin to your PATH.

open your .bashrc and edit/add the following

PATH=$PATH:/Tomcat_Dir/bin/


2) Add links to the startup and shutdown scripts in you bin directory.

ln -s /Tomcat_Dir/bin/Startup.sh /bin/tom_start.sh

ln -s /Tomcat_Dir/bin/Shutdown.sh /bin/tom_stop.sh


3) Alias the startup and shutdown scripts.

alias Tomstart='/Tomcat_Dir/bin/Startup.sh'

alias Tomstop='/Tomcat_Dir/bin/Shutdown.sh'

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.