Let’s say for example you want to run hugo server
, but instead of on the localhost you want to run it over your VPS server (or even from your home server). Without the bash script, you’ll need to run:
hugo server --bind=<IP ADDRESS> --baseURL=http://<IP ADDRESS>:1313
Let’s name the bash file serve.sh
nano serve.sh
#!/bin/bash
hugo server --bind=<IP ADDRESS> --baseURL=http://<IP ADDRESS>:1313
Don’t forget to include #!/bin/bash
at the first line.
If you need to make multiple commands, enter each command in separate lines, and end the file with exec bash
, like for example:
#!/bin/bash
cd appdata/app/subfolder
PS1='$(whoami)@$(hostname):$(pwd)# '
exec bash
Ctrl+O
to save the file
Ctrl+X
to close the file
sudo chmod +x serve.sh
Enter password as may be necessary.
./serve.sh
Assuming we don’t get into permission problems, our script should be working well.