This question already has an answer here:

I want a custom command named something like "ServerStart" or something which is a combination of two commands, one after the other.

  • The first command would be cd .Server
  • The second being java -Xmx7168M -Xms7168M -jar server.jar

How do I do this so this becomes one Terminal command?

marked as duplicate by Radu Rădeanu command-line Jul 15 '14 at 8:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Usually alias is used to make a short custom command for one or more long commands. See How to create a permanent "alias"?

You can combine two command as,

command1 && command2

Then command2 will be issued if command1 is successfully executed. So make an alias like,

alias ServerStart='cd /path/to/.Server && java -Xmx7168M -Xms7168M -jar server.jar'

Source ~/.bashrc as . ~/.bashrc. After that the command ServerStart will issue both the commands together for you.


Instead of having the first command be cd .Server you can have the command be java -Xmx7168M -Xms7168M -jar /full path here/server.jar

Put it in a text file and save it at /usr/bin/ServerStart. chmod +x /usr/bin/ServerStart

  • Instead of /usr/bin/, you can create a folder named bin (or whatever) in your home folder, then add it your PATH by appending the line export PATH="$HOME/bin:$PATH" to your .bashrc file. – edwin Jul 15 '14 at 1:36

You could use alias command .

For more help visit this site Site .

Open terminal :

alias ServerStart=' cd /path/to/.Server ; java -Xmx7168M -Xms7168M -jar server.jar '

So now when you type ServerStart in terminal it will execute the two commands .

To save , so you can use it all the time add the following in you ~/.bashrc file .

ServerStar() {
   cd .Server
    java -Xmx7168M -Xms7168M -jar server.jar

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