I can put aliases in my .bashrc (or files called from it) and they then work in my shell.

I can also then create other aliases at the command line, e.g.

alias aaa='ls'

and it works. aaa does an ls operation

But if I put that alias definitions in a file, say aaa_alias, make it executable and then try and use it, it is not recognized.

I call it with ./aaa_alias and get no error. But the aliases does not sem to have been defined in my shell.

Why not? What am I doing wrong? How can I have a small number of aliases ina separate file than I just use occasionally when I want and so I invoke it when I went them.

enter image description here

  • 2
    Have you tried sourcing the file instead of executing it? Sep 29, 2019 at 23:02
  • That is the answer Sep 29, 2019 at 23:03

1 Answer 1


In order to insert the contents of a file into your current session, you need to source the file, not execute it.

. my_file

When you were just executing the file, the aliases were being set in a subshell and therefore had no effect on your current session.

  • Though I imagine this is a duplicate... Sep 29, 2019 at 23:13

You must log in to answer this question.

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