Linux command alias alias permanent

In order to more easily enter linux command, instead of complex combinations of commands, you can use the alias to achieve, but the alias is currently only effective, after exiting the bath, just set the alias command alias will disappear.

How to use it permanently? please look below:

First, if you want to use an alias in a different shell session, you need to add them to the file shell to save the alias of. In most cases, this file is not .bashrc, is .bash_aliases.

The system I use CentOS, is preserved in the .bashrc years. (Or you can enter the home in the root directory: ls -a ~ see that document which is a)

alias command format is: alias [alias name] = '[command]' as: alias mv = 'mv -i'

If you want to permanently save, put it to the editor to the next /root/.bashrc, then: wq save and exit, but have to reload the alias file to take effect, an executable # .bashrc (see note below).

(After such changes take effect only root user alias, to ordinary users effective, .bashrc under normal user directory must also make the same changes!)

First, a period (.), After a point

 
 

Face followed by a space, followed by the file name (the file name with a dot as a start). Now add the new alias will be able to run. Because each time adding a new alias will need to reload the alias file, so more than once to add several aliases, it is a good idea.

 

linux alias settings permanent

Edit the file: /.bashrc

alias

cdhome = 'cd ~'

cdroot alias = "cd /"

alias gpull='git pull'

alias gci='git commit -a'

alias gpush='git push origin HEAD:refs/for/master'

alias gst='git status'

alias dj='cd usr/python/lib/python3.7/site-packages'

After saving the file, run:

source ~/.bashrc

(Or do not take effect)

On it.

If not enough, it indicates that there is no ~ / .bash_profile file, or the file is not performed .bashrc file.

(.Bash_profile file is a file when the user logs terminal will be automatically executed, the general this file will be called .bashrc)

If so, you need to open (if not create) files:

~/.bash_profile

Inside add a line:

source ~/.bashrc

Ok.

I tested ok in mac system.

or

vim /etc/profile

Set alias content

 

Guess you like

Origin www.cnblogs.com/weifeng1463/p/12148652.html