Use of command alias in CentOS
In Linux, mis-typing the rm command is an easy task. Therefore, it is very important to avoid the harm caused by the rm command. In Linux, it is actually very easy to implement rm command interaction. You only need to simply use the rm-I command. However, if you input this information each time, the number of times you press the keyboard increases. here we can use the Linux alias to solve this problem. The following describes how to use the alias command: first, there are many methods to query commands, such as man and info, which can be used for the longest time. However, the two methods provide a lot of help results, here, we use the help command to clear and clean the output results, as shown in: From the query results of the command, we can see that the usage of this command is: alias [-p] [name [= values]...] the-p option can list all the commands with aliases in the system, as shown in the following figure: shell has several important configuration files:/etc/profile: this file sets environment information for each user in the system. This file is executed when the user logs on for the first time. And collect shell settings from the configuration file in the/etc/profile. d directory.
/Etc/bashrc: execute this file for every user running bash shell. When the bash shell is opened, the file is read.
Current user variable:
~ /. Bash_profile: each user can use this file to input the shell information dedicated to their own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file.
~ /. Bashrc: This file contains bash information dedicated to your bash shell. This file is read when you log on and every time you open a new shell.
~ /. Bash_logout: execute this file every time you exit the system (exit bash shell. Save the ls command in ~ /. In the bashrc file, l., ll, ls are saved in/etc/profile. d/colorls. in the sh file, the alias of the which command is saved in/etc/profile. d/which2.sh file. The command opposite to the alias command is the unalias command, which can cancel the alias of the command. Note: If you only use the alias command to create an alias instead of saving it in a file, the alias can only be used in the shell terminal. This alias cannot be used for other interruptions, if you want to use the alias for another terminal or restart it, you need to save it in the file. Generally, you need to save the alias defined by yourself in ~ /. Bashrc file.