Friday, May 17, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1711  / 3 Years ago, thu, october 14, 2021, 10:15:58

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?


More From » command-line

 Answers
6

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.


[#24130] Friday, October 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sertold

Total Points: 445
Total Questions: 123
Total Answers: 113

Location: Burundi
Member since Wed, Sep 28, 2022
2 Years ago
;