2

I have written on .bash_aliases to run my shell script:

alias testing='./testing' 

Problem I'm having right now is that it won't run the shell script.
On the terminal it says the "command not found".
May I know if anything wrong with what I've typed?


Edit:

I've found out that it only work after I typed source ~/.bashrc

Problem now is how do I run source ~/.bashrc upon starting of Ubuntu when I log in?

Radu Rădeanu
  • 169,590
Unknown
  • 195
  • 3
  • 4
  • 9

1 Answers1

3

You should insert the complete past for the script:

alias testing='/path/to/testing'

If you use alias testing='./testing', the alias will work only your current working directory is the same with the script path.

Or you can add the path of the script to the PATH. Furthermore, if you use this method you will not need an alias anymore. See How to add a directory to the PATH? in this sense.

After you edited .bash_aliases file, to prevent a terminal restart or a re-login, you can use one of the following commands:

source ~/.bash_aliases

or

. ~/.bash_aliases
Radu Rădeanu
  • 169,590
  • Edited.
    I've found out that it only work after I typed source ~/.bashrc

    Problem now is how do I run source ~/.bashrc upon starting of Ubuntu when I log in?

    – Unknown Aug 20 '13 at 06:24
  • It will not work when you change the current working path in terminal (let say cd /). source ~/.bashrc is used precisely to prevent a terminal restart when you change the bash initialization files like ~/.bashrc or .bash_aliases - a re-login is too much – Radu Rădeanu Aug 20 '13 at 06:31
  • How to first run the "source" when an user execute terminal? Like a startup application on Windows – Unknown Aug 20 '13 at 07:30
  • @Guest I don't see any reason to do this... Anyway, if you have new questions, don't hesitate to use ask question button. – Radu Rădeanu Aug 20 '13 at 07:34