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

How to customize History output format by Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this article "Linux how to customize History output format", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Linux how to customize History output format" article.

The Linux system uses the History command to view the running records of the system to identify some problems. However, there is often no time and other information in the data output by History.

The specific methods are as follows

Log in to the server as root user and create a new file history_command under / etc/profile.d/

Vim / etc/profile.c/history_commandexport HISTFILE=$HOME/.bash_historyexport HISTSIZE=1200export HISTFILESIZE=1200export HISTCONTROL=ignoredupsexport HISTTIMEFORMAT= "`whoami`% F% T" shopt-s histappendtypeset-r HISTTIMEFORMAT

Source / etc/profile.c/history_command to make it work, then hit the history command to see:

# history 51008 root 2015-09-11 08:54:20 vim / etc/profile1009 root 2015-09-11 09:13:17 history | less1010 root 2015-09-11 09:15:49 vim / etc/profile1011 root 2015-09-11 09:43:20 cat / etc/profile.d/history_command1012 root 2015-09-11 09:44:59 history 5

The time is up, and the files under / etc/profile and / etc/profile.d/ will be executed automatically when the user interactive login, so every command that the user logs into the machine will be recorded in the file specified by HISTFILE and written as an append.

The most critical part of the configuration is export HISTTIMEFORMAT= "whoami% F% T", which specifies the output format of history.

The above is about the content of this article on "how Linux customizes the History output format". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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

Development

Wechat

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

12
Report