Link to home
Start Free TrialLog in
Avatar of alpha_dk
alpha_dk

asked on

how to create a persistent alias?

i would like to create an alias for example "reboot" = 'shutdown -r now'
or "halt" = 'shutdown -h now'

whenever i create an alias i find that it is destroyed on reboot. surely there is a way to make them persistent?
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Put these commands in your .profile file (or, if you use a different shell, into one of the configuration files for your shell).
Avatar of alpha_dk
alpha_dk

ASKER

thanks kremer i assume you mean .bash_profile?

what exactly would i write in there?
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is a standard sequence that bash loads config files, and each file is supposed to contain specific information.  User specific Alias commands belong in ~/.bashrc.

-Karl
Karl,
most people don't know (and don't care) about the differences, but if you want to direct somebody to a specific file, you should provide some background information about why this is the correct file :-)

An alias will work in all the files that I've listed, however there is one file that will have one small advantage over other's: The .bashrc file will be read only for interactive shells, which means that you don't slow down the loading of a shell that's used for e.g. a shell script by defining aliases.
khkremer,

Thank you for clarifying that.