Use of command aliases in Linux

Source: Internet
Author: User

in a Linux system, the mistake of the RM command is a very easy thing to happen. Therefore, how to avoid the damage caused by the RM command is very important. In the Linux system to do the RM command interaction is actually very simple, just need to simply use the Rm-i command. But each time this input will cause the number of keystrokes to increase, here we can use the Linux alias method to solve the problem. Let 's start with the use of the alias command:There are a number of ways to query the command, the longest use of man, info, etc., but the use of these two ways to give a lot of help, here we use the aid command, the output results are clean, as shown in:
From the query results of the command we can see that the command is used in the following way: Alias [-P] [name[=values] ...] Where the-P option can list all the aliases in the system now, as shown in the following:

       The shell has several important configuration files:      /etc/profile: This file sets the environment information for each user of the system, and the file is executed when the user logs on for the first time. and collect the shell settings from the configuration file of the/ETC/PROFILE.D directory.
/ETC/BASHRC: Execute this file for each user running the bash shell. When the bash shell is opened, the file is read.
Current User variables:
       ~/.bash_profile: Each user can use the file to enter shell information dedicated to their own use, and when the user logs in, the file executes only once! By default, he sets some environment variables to execute the user's. bashrc file.
       ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
       ~/.bash_logout: Executes the file each time it exits the system (exiting the bash shell). The LS command in the ~/.BASHRC file, L, LL and LS are saved in the/etc/profile.d/colorls.sh file, and the alias of the which command is saved in the/etc/profile.d/which2.sh file.
       The command opposite to the alias command is the Unalias command, which cancels the alias of the command.       Note: If you create an alias with the alias command and do not save it in a file, the alias can only be used in that Shell terminal, the alias cannot be used by other interrupts, and you will need to save it in a file if you want to continue using the command alias after another terminal or reboot. Typically, your own defined aliases are saved in the ~/.BASHRC file.

Use of command aliases in Linux

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.