Friday, May 3, 2024
72
rated 0 times [  72] [ 0]  / answers: 1 / hits: 105663  / 2 Years ago, tue, november 1, 2022, 11:16:05

I'm a web developer. When I want to start working, always i'm executing some command on terminal. For example:



sudo service apache2 start
sudo service mysql start
sublime


For speed up this process, I create a .sh file which contain these commands.



Now, when I want to start working, I'm just executing this .sh file and all services (mysql, apache2 etc.) starting.



Is it possible to create a custom command for this? For example if I type sudo start-working to terminal, it will execute these commands


More From » command-line

 Answers
7

A common way people handle this is to make a bin directory in their home directory: mkdir ~/bin



Then, you can put your custom scripts in there: mv start-working ~/bin



Make sure your script is executable: chmod +x ~/bin/start-working



Add this to the bottom of your ~/.bashrc file (if you're using bash, which you probably are): export PATH=$PATH:~/bin



Now log back in and out of your terminal and you should be able to simply type start-working, and your script will execute.



Now that your path is setup, any new scripts you drop into your ~/bin you can just type in the name of.


[#39513] Thursday, November 3, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pardsea

Total Points: 290
Total Questions: 115
Total Answers: 98

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
;