Daily Linux Command Learning-historical Command query (history, FC, alias)

Source: Internet
Author: User
Tags aliases

The Linux history mechanism numbers the commands entered on the command line and saves them to maintain the command history. Commands entered during a logon session are saved in shell memory and added to the history file if the Abort command is removed.

1. Arrow Symbol Direction key

Use the arrow keys on your keyboard to get historical instructions from a history file, and you can make changes after you access the history commands.

2. History directive

History is a built-in instruction for the system to display a list of instructions saved by the. bash_history file and give the instruction a number.

3. FC Directives

The FC directive can be used to output a list of historical commands, or you can edit the contents of a history instruction by invoking the VI editor.

Grammar:

FC [-E ename] [-LNR] [first] [last]

Options:

-L: Show History Command

-N: No numbering is displayed when the history command is displayed

-R: Reverse order Display History command

-E: Edit the history command using the specified editor, such as VI, if the parameter option is not available, FC is only the output display for the history instruction list.

Parameters:

First: The starting instruction number, which specifies the starting number of the list of instructions to be edited or displayed

Last: Terminating instruction number, specifying the ending number of the list of instructions to be edited or displayed

Instance:

1) $ fc-l n #从第n个指令开始显示 (n>0)

2)$ fc-l-N #显示最近执行过了n个指令

3)$ fc-l m n #显示编号为m ~n History Instruction segment

4)$ FC N #编辑编号为n的历史指令

5)$ fc-e vi-l m n #调用vi编辑器 and save the specified instruction segment (M~N) to the temp file (/tmp directory)

Alias directive

The author in the study of the history of the command query, inadvertently saw the alias directive, and for the alias directive is more unfamiliar, so in this way to learn a bit.

Role:

Displays a list of all instructions that have aliases set or sets an alias for the directive.

Common related directives:

1) Show list of instructions with aliases

Command: $ alias

2) Setting aliases

Command: $ alias [alias]= ' directive name '

3) Delete aliases

Command: $ unalias [alias]

The system's instruction alias settings are generally performed in the file. BASHRC.

Daily Linux Command Learning-historical Command query (history, FC, alias)

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.