What is the difference between Linux command aliases and resource files
This article mainly introduces "what is the difference between Linux command aliases and resource files". In daily operation, I believe many people have doubts about the difference between Linux command aliases and resource files. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the difference between Linux command aliases and resource files?" Next, please follow the editor to study!
Alias
An alias is a shortcut to a command. It is useful to create shortcuts for long commands that need to be executed frequently but take a long time to enter. The syntax is:
Alias ppp='ping www.baidu.com'
They are not always used to shorten long commands. The important thing is that you use them for tasks you often perform. Possible examples:
Alias update='yum update'
So you can just use update to complete the command operation of yum update.
The problem with setting an alias in a terminal is that once the terminal session is closed, the alias is lost. To set them permanently, use a resource file.
Resource file
Resource files (that is, rc files) are configuration files that are loaded at the beginning of a session or process (when each user opens a new terminal window or starts a new program such as vim). For ZSH, the resource file is .zshrc, and for bash, it is .bashrc.
To make aliases permanent, you can put them in the resource file. You can use the text editor of your choice to edit the resource file. Vim is used here:
Vim $HOME/.zshrc
Or for bash:
Vim $HOME/.bashrc
In this way, after we create a new terminal, we can still use the commands we created to complete some longer command operations.
At this point, the study on "what is the difference between Linux command aliases and resource files" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!