Shell Alias – How to Make an Alias Permanent

aliasshell

I have created an alias:

alias shh='sqlplus hfdora/hfdora@hfd1"  

After creating this alias I was able to enter my database only by typing shh.

But after closing my shell, I wasn't able to find the alias next time. Even after typing only alias, shh was not showing in the list.

Is there any file to make an alias permanent so that it will not be erased?

Best Answer

For ksh:

printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd1" >> ~/.kshrc
source ~/.kshrc

For bash:

printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd1" >> ~/.bashrc
source ~/.bashrc

For zsh:

printf "%s\n" "alias shh='sqlplus hfdora/hfdora@hfd1" >> ~/.zshrc
source ~/.zshrc

Use source for the instant effect


And as @glennjackman said:

A note to readers: ~/.kshrc is for ksh93. For ksh88, either put your aliases in ~/.profile, or use ~/.kshrc but add this to your ~/.profile:

export ENV=$HOME/.kshrc