Use of command alias in CentOS

Source: Internet
Author: User
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. 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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.