Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to Ubuntu and currently on it because of assignment. I would like to ask few questions:

  1. How do I make new command to run a shell script? For example, when you type passwd on terminal it runs the executable file on /usr/bin/passwd. How do I make it the same like my file?

  2. How do I change my shell script into a executable file like the passwd?

share|improve this question

Your script should look like:



Save it in a file, let say or simple password, then make it executable using next commands in terminal:

cd /path/to/  #or cd /path/to/password
chmod +x     #or chmod +x password

To run it from terminal, just use the following command:

./            #or ./password


/path/to/     #or /path/to/password

To run it only using:              #or password

you must to add the path of the script to the PATH. See How to add a directory to my path? in this sense.

share|improve this answer
I want to run it without the "./" part. Is it possible? – Unknown Aug 19 '13 at 19:15
I'm sorry, I forgotten another criteria which is I want to run with out the ".sh" also. That means I want to run my file with just the file name on terminal. For example: passwd – Unknown Aug 19 '13 at 19:24
@Guest Ok, save the script eith the name password. There is no problem by doing this. – Radu Rădeanu Aug 19 '13 at 19:25
Cool. Will try it out soon. Thanks alot for your help. – Unknown Aug 19 '13 at 19:27
@geirha Wake up! A file with .sh extension is primarily associated with a script designed to run at an UNIX/LINUX command prompt and finish. There is no problem if other kind of files have the same extension or if you don't want to use an extension for this type of file. – Radu Rădeanu Aug 20 '13 at 17:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.