Alias implements command aliases

Source: Internet
Author: User
Tags aliases

Need to enter/srv/www/app/account This directory frequently, each time to have to repeat the input of this long string of paths into the directory, it seems cumbersome and lengthy, so you can "cd/srv/www/app/account" such a command to take an alias, Enter the directory every time you just type the alias

The Linux system provides a useful tool called Alias, which allows us to set an alias for a number of commands that need to be used frequently but too verbose, and then just enter a short alias to achieve the same effect.

Usage: alias [-P] [Name[=value] ...] Note the ' = ' and the string cannot contain spaces between

Use of the alias command:

1. Displays all aliases for the current setting:

2. Show only the meaning of an alias to enter alias name, such as:

3. Set an alias for the command to enter the alias new command = ' original command option/parameter ', for example:

4. Canceling command aliases

5. Execute multiple commands at once

You want to do the following:

1. Enter the catalogue/root

2. View the files in the directory

3. Switch back to the root directory/.

Usually this requires three commands cd/root, LS, CD/ , if you need to use it frequently then we can do it all with a command by customizing the command

A. First use the command type to customize the command name to see if the custom command name is being used by the system. You can see that the test command name is already occupied by the system, so it cannot be used, and the loo command name can be used by query.

B. Use the command alias to create a custom command:alias loo= ' CD/ROOT;LS;CD/' . Note that the command is used in a format where there is no space between the semicolon and the semicolon.

C. Test the custom command, when the input command Loo , found that the system completed the cd/root, LS, CD/ three command, indicating the success of the setup.

You can also directly use the command alias to query the system for the addition of loo this custom command.

D. If you want to delete this custom command, you can use the command unalias to customize the command name to complete. After execution, it is found that the loo command is no longer present, and there is no loo command in the custom command library.

The alias command set in this way is only valid for the current login environment, and it is not valid to log back on after exiting, how can the alias command remain valid?

That is, modify the RC configuration file, the process of setting up aliases into the user's script initialized after the system startup, the user only need to modify the ~/.BASHRC file, add the alias command you want to set to

Want to add a command oo input oo can go directly into the/MNT/HGFS/D/WORK/PROJECT/ASID/5.CODE/TRUNK/ASID/ASID/WMS directory

Method:VI/ETC/BASHRC

Add alias oo= ' cd/mnt/hgfs/d/work/project/asid/5.code/trunk/asid/asid/wms/' to the end of the file and save exit

Perform SOURCE/ETC/BASHRC to make configuration effective

Complete!

Practical Scenarios:

Capture IP 192.168.91.128 Port 22, 80, 8048 packets
Tcpdump-i any host 192.168.1.123 and! Port! Port and! Port 8048-w/opt/temp.cap

Nmon's command.

Alias implements command aliases

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.