I'm new to Ubuntu and currently on it because of assignment. I would like to ask few questions:
How do I make new command to run a shell script? For example, when you type
passwdon terminal it runs the executable file on/usr/bin/passwd. How do I make it the same like my file?How do I change my shell script into a executable file like the
passwd?
1 Answer
Your script should look like:
#!/bin/bash
passwdSave it in a file, let say password.sh or simple password, then make it executable using next commands in terminal:
cd /path/to/password.sh #or cd /path/to/password
chmod +x password.sh #or chmod +x passwordTo run it from terminal, just use the following command:
./password.sh #or ./passwordor
/path/to/password.sh #or /path/to/passwordTo run it only using:
password.sh #or passwordyou must to add the path of the script to the PATH. See How to add a directory to the PATH? in this sense.
10