Linux: alias takes effect permanently

Source: Internet
Author: User

Linux: alias takes effect permanently

Alias allows you to use a shorter name to redefine Shell commands in Linux, thus simplifying command line input.

If you often deal with the CLI, using alias will not only save time, but also improve efficiency.

Basic usage: the basic usage of alias is: alias new command = 'original command-option/parameter '. For example, alias l = 'LS-lsh' will redefine the ls command. Now you only need to enter l to list directories.
Get the alias: directly enter the alias command to list all the alias defined in the current system.
Delete alias: to delete an alias, you can use the unalias command, such as unalias l.

The above method is only temporary. If it is restarted once, it will become invalid. What if we want to permanently activate a command?

Open. bashrc (it should be the ubuntu release, and other releases may be able to modify. bash_profile ).
......
# Some more ls aliases
Alias ll = 'LS-alf'
Alias la = 'LS-'
Alias l = 'LS-CF'
......
Method 1: Add alias xx = 'xxxxx' directly to our environment variable file'
Method 2: There is a sentence in. bashrc
# You may want to put all your additions into a separate file like
#~ /. Bash_aliases, instead of adding them here directly.
That is to say, you can create another file to store your own alias information.
Example
$ Cd
$ Vi. bash_aliases
Enter the command alias rm = 'rm-I 'you want to set in the file, and then save and launch

$ Source. bashrc # Make Our Environment effective

For example:

Alias ls = 'LS-ltr'
Alias cat = 'nohup $ CAT/start_navicat &'
Alias db = 'mysql-uroot-proot'

......

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.