2

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?

4

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
  • I am using .kshrc.... so it will be in ~/.kshrc? – pmaipmui Jul 14 '15 at 15:30
  • @Nainita Yes, do that =) – A.B. Jul 14 '15 at 15:31
  • What are those printf statements supposed to do? They're not updating the *rc file – glenn jackman Jul 14 '15 at 15:38
  • @glennjackman sorry, I forgot >> =\ – A.B. Jul 14 '15 at 15:39
  • 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 – glenn jackman Jul 14 '15 at 15:42
2

put your alias inside your ~/.bash_aliases file.

If it's not present create one and call it from ~/.bashrc

OR you can directly put it inside your ~/.bashrc

  • I am using .kshrc – pmaipmui Jul 14 '15 at 15:30
0

Put it in your .bashrc file. Then it will be an alias in every instance of Bash shell you open.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.