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 typepasswd
on 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
?
Best Answer
Your script should look like:
Save it in a file, let say
password.sh
or simplepassword
, then make it executable using next commands in terminal:To run it from terminal, just use the following command:
or
To run it only using:
you must to add the path of the script to the PATH. See How to add a directory to the PATH? in this sense.