History commands in Linux

Source: Internet
Author: User

The history command, which is a command typed at the command line before the login session.

There are two ways to query history commands in Linux

    • History command
    • Hidden files in the current user directory. Bash_history
I. History

Scope

    1. Currently logged in user
    2. Previous logon session and current logon session

This means: History queries the commands that are typed by the current logged-on user during the current session and before the logon session.

How history works
Linux maintains a history command memory cache, the command currently typed by the session is written to this cache, and the history command recorded in the. Bash_history is loaded into the cache when the current user logs in.

[[email protected] ~]$ history1  su - root2  ps -aux|grep tserver3  cd /opt/server/tserver4  cd Bin/5  cd tserver6  tail -f log/hplugin/tserver_plugin_hik.log 7  tail -f log/cluster.log8  less log/cluster.log9  cd ..

History has a lot of parameters, here only the next-c parameter. -C: Used to clear the memory cache of history, but does not delete the. bash_history historical command.

Two. View. bash_history
[[email protected] ~]$ cat ~/.bash_historysu - rootps -aux|grep tdacd /opt/hikserver/tdacd Bin/cd tdatail -f log/hplugin/tda_plugin_hik.log tail -f log/cluster.logless log/cluster.logcd ..

Configure record History command bar number

In the "/etc/profile" configuration file, you can configure whether the historical Operations command is logged.
Vi/etc/profile

HOSTNAME=`/usr/bin/hostname 2>/dev/null`HISTSIZE=1000

You can change the size of the record History command by modifying the size of the histsize. If you change to 0, the history command is not recorded. Default is 1000 bar

History commands in Linux

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.