• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Check Linux Command History In Linux With Timestamp And Date

How To Check Linux Command History In Linux With Timestamp And Date

By Sourabh / July 5, 2023 Category: How To, Ubuntu

You can check Linux command history with timestamp. Let us learn how to check command history in Linux with date for all users.

Linux History Command With Timestamp And User

To enable timestamps in the history command, you have to export the HISTTIMEFORMAT variable using the following command:

export HISTTIMEFORMAT="%F %T "

In the above command, %F displays the date in YYYY-MM-DD format and %T displays the time in HH:MM:SS format.

If you want to also view username in command history, run the pstree command in the following manner:

$ original_user=${SUDO_USER:-$(pstree -Alsu "$$" | sed -n "s/.*(\([^)]*\)).*($USER)[^(]*$/\1/p")} $ export HISTTIMEFORMAT="<%F %T> (${original_user:-$USER}) [$$] "

NOTE: The above command works for the current session. Once you logout it will reset to the default format of your system.

To permanently change the history format, you will have to edit ~/.bashrc file.

Open the file using the following command:

$ vi ~/.bashrc

Now add the following line to set the history entry’s format:

export HISTTIMEFORMAT=”%F %T “

Now save and close the file.

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap