Linux Modify History

Source: Internet
Author: User

1. Cat ~/.bash_history

2. History | More

Enter the keyboard----------line

Space Keyboard---------------one page

3,! 103 Execution of 103th order

Problem

In the process of using bash, we may want to .bash_history document more useful historical commands, so that we can query later, and here's a workaround.

Change the default history

> vi ~/.bashrc# 添加# 忽略[连续]重复命令HISTCONTROL=ignoredups# 清除重复命令# HISTCONTROL=erasedups# 忽略特定命令HISTIGNORE="[ ]*:ls:ll:cd:vi:pwd:sync:exit:history*"# 命令历史文件大小10MHISTFILESIZE=1000000000# 保存历史命令条数10WHISTSIZE=1000000

The above configuration can be done by set | grep HIST Viewing the options.

Multi-terminal Append

When multiple terminals are opened and one of the terminals is closed, the command history of the other terminals is overwritten, where we use the Append method to avoid overwriting the command history file .bash_history . Open ~/.bashrc the file again to add the following sentence.

> vi ~/.bashrc# 添加shopt -s histappend

More shopt options can be echo $SHELLOPTS viewed by command.

Effective ¶

source ~/.bashrc`

or close the bash terminal and reopen it.

If you need to use VI mode in bash to speed up your input, check this article to Open Bash VI mode

After a while, you'll be able to take a ~/.bash_history file and admire the commands you've been knocking over.

enjoy!

Linux Modified history

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.