Super User is a question and answer site for computer enthusiasts and power users. 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 have script on my Virtual machine that i would like to run without []$ ./myscript

[studentuser@CentosStudentSvr ~]$ myscript

-bash: iduser: command not found

otherwise it errors:

-bash: iduser: command not found

how can I fix it?

Thank you

share|improve this question
what exactly do you mean "run it without []$ ./myscript? – MattDMo Jun 6 '13 at 18:28

If you type myscript then your shell will look in your PATH to see if it can find the command named myscript. Unlike with windows your current directory is not in your path by default.

Which means you either want to:

  1. add it to your path for now (munually)
  2. add it to your path every time you start (edit the startup script in your folder. Which ones depends on which shell you use. Often .profile or .bashsomething)
  3. Or specify the full path to the binary. E.g. ./iduser or /home/user229525/iduser.

If the current directory (.) is already in your path then check your program.

  • Is it executable? (ls -l, look for the x in rwx)
  • If it is a script, does it start with a shebang? (e.g. is the first line #!/usr/bin/env bash).
share|improve this answer
Thank you very much, but didn't work and I still have to use ./myscript to work :( – user229535 Jun 6 '13 at 21:38
What is the output from echo $PATH? Does it include . or /home/studentuser ? Did you try PATH=$PATH:. (Appending dot to the end of the path). If that works add it to your profile or other startup scripts. – Hennes Jun 7 '13 at 11:28

Bash looks for the "commands" in the paths enumerated in the $PATH variable. Move the script to the /usr/bin or another folder mentioned in the $PATH (or add the folder you have script in to the $PATH).

Also you can define an alias for the bash running alias myscript="bash /path/to/script/myscript". (please verify the syntax yourself, I am not sure right now)

share|improve this answer
thank you ,i will check and let you know – user229535 Jun 6 '13 at 18:39
still need the ./ script – user229535 Jun 6 '13 at 23:00
You are probably doing something wrong. I tested it :) – Fiisch Jun 7 '13 at 5:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .