Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction and use of history Command in linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Manual description

Display or manipulate the history list

Display or manipulate a list of command history

2. Conceptual distinction

The history list is in the memory cache, and the history file is in the hard disk. History list takes effect for the current session. History file takes effect for all sessions. When logging in to the system, the system will automatically add history list, and when you exit the system, the commands in history list will be automatically written to history file.

The default location for saving the bash_history history list

The setting location of the environment variable for the current bash_profile user

Default setting location of / etc/profile system environment variable

Variables about HISTORY:

Number of entries in the history of HISTSIZE commands

HISTFILE specifies the history file, which defaults to ~ / .bash_history

HISTFILESIZE: the number of entries recorded in the command history file

HISTTIMEFORMAT: HISTTIMEFORMAT= "% F% T" display time

History usage:

History [- c] [- d offset] [n] or history-anrw [filename] or history-ps arg [arg...]

Display the history list with line numbers, prefixing each modified entry with a''. An argument of N lists only the last N entries

Displays a list of history with line numbers and prefixes each modification

An entry with "". The parameter N lists only the last N elements.

Options:

-c: clear the history list by deleting all of the entries

Clear the history list by deleting all entries

-d offset: delete the history entry at offset OFFSET

Delete the history entry at the offset position (that is, delete the history entry of the specified number)

-a: append history lines from this session to the history file

Trace the history line of this session to the history file

-n: read all history lines not already read from the history file.

Read all history lines that have not been read from the history file

-r: read the history file and append the contents to the history list

Read the history file and append it to the history file

-w: write the current history to the history file and append them to the history list

Writes the current history to the history file and appends them to the history list.

-p: perform history expansion on each AGR and dispay the result without storing it in the history list

Perform a history extension on each parameter and display the results without storing it in the history list

-s: append the ARGs to the history list as a single entry

Add all ARGs as separate entries to the history entry.

Other more common uses:

(1): view history command

History # Show all historical commands'

History 10 # shows the last 10 commands

(2) check the number of default historical commands:

Echo $HISTSIZE

This environment variable is defined in / etc/profile

(3) order re-invocation

Ls! 407 # recall the 407th positive command in the history command

Ls!-4 # recall the penultimate command in history

History commands are stored in two parts: .bash _ history and in memory.

When exiting normally, historical commands in memory are stored in .bash _ history

(IV) execute the penultimate command that begins with shut

! shut

(5) execute the previous command containing go

!? go

(6) to execute the orders that have just been executed

1. Turn the up and down keys

2!-1

(7) search for executed orders

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report