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 have written this simple type alias script in my bin dir in home

alias kp='ls –L'
alias ldir='ls –aF'
alias copy='cp'

and saved it in the name myenv.Then I have changed the mode using

chmod +x /bin/myenv

then execute it using the command


but after this when I use kp it says kp command not found.Why?

share|improve this question

Your script runs in a sub-shell by default. (It opens a new shell and runs your script. After the script has finished running, its modified environment is destroyed.)

If you'd like to change your current shell environment settings you have to:

source myenv


. myenv

See man bash Shell Builtin Commands / Source.

share|improve this answer

First, because character that you used in alias kp='ls –L' and alias ldir='ls –aF' is not the same with - (you can see that is a little bit longer). Try:

alias kp='ls -L'
alias ldir='ls -aF'
alias copy='cp'

Just copy and paste from above.

Second, if you want that the script to have the expected effect, just put this line in ~/.bashrc file:

source /bin/myenv

Anyway, the best way to create aliases in Ubuntu is to use this method:

share|improve this answer
Thanks.. But creating alias isnt my goal. I am just learning to create shell scripts – Tamim Ad Dari Jun 24 '13 at 8:38
@TamimAdDari Ok, if the answer was useful, you should accept it. In general you should do this. See What should I do when someone answers my question? and What does it mean when an answer is "accepted"?. – Radu Rădeanu Jun 24 '13 at 9:19
alright.. thanx... – Tamim Ad Dari Jun 24 '13 at 15:47

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.