Creating Multiple Temporary Aliases in Linux

alias

I am not a root user & I don't have access to the global alias file which has all the aliases created, but I want to create some aliases which remain active only for the session I am logged in.
I use the command alias x='cd /parent/child' to create an alias which will enable me to just type x on the console & I change dir to /Parent/Child .

However, I want to create multiple aliases & I don't want to type each alias I create every time.

I tried putting all the alias='do this' lines in a file (gave it 777 permission) hoping that on running the file all these aliases would be created every time I login. But that didn't happen.

ex :

alias x='cd /parent/child'
alias y='cd /a/b/c'
alias z='tail -0f some.log'

I also tried this in the file but in vain:

alias x='cd /parent/child';alias y='cd /a/b/c';alias z='tail -0f some.log'

None of the alias names I tried were already present in the global alias. (I typed alias & saw the output on the screen).

Best Answer

generate all you session alias in a file, for instance alias.txt

alias x='cd /parent/child'
alias y='cd /a/b/c'
alias z='tail -0f some.log'

then use

 . ./alias.txt

You sould have all you alias in alias list, for this single session.

Edit:

Be sure to use

. ./alias.txt

not

./alias.txt

In former case, content is read 'as if typed', while the latter case will define alias in a shell that will exit.

Related Question