WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / ESXi / Quick Tip - "poor mans" history command in ESXi

Quick Tip - "poor mans" history command in ESXi

02.19.2015 by William Lam // 1 Comment

When I am logged into the ESXi Shell, I often forget that history command is not implemented in ESXi which can be helpful when recalling the list of operations that had been executed in the past. I especially rely on the history command when I am tinkering around with things and once I am successful with the end result, I can easily go back and see the exact steps I took. Recently, I tried running history command only to be let down again as I forgot it was not implemented 🙁

I was thinking there had to be a way on ESXi and then it hit me! Starting with ESXi 5.1, all operations executed in ESXi Shell and Console were automatically logged to /var/log/shell.log. The information I was looking was there but instead of having to manually view the contents of the log, I could simply create an "alias" to  a history command which could display the last N-number of entries using the tail command.

Here is an example alias to "history" command to view the last 50 lines in /var/log/shell.log:

alias history="tail -50 /var/log/shell.log"

To make the alias permanent and persist across reboots, we just need to add the entry to /etc/profile.local

Now, I can run the history command on ESXi and get exactly what I want.

Screen Shot 2015-02-18 at 9.29.41 PM
Note: Entries in /var/log/shell.log contain more operations executed by all users. You can further refine the aliased command to search only for the current user, such as the root account.

More from my site

  • ESXi on palm size iKOOLCORE R1
  • Quick Tip - Automating ESXi local user passwords using SHA512 encrypted hashes
  • ESXi Advanced & Kernel Settings Reference
  • High-end Dell Precision 7770 & 7670 laptops with 128GB memory for ESXi
  • Quick Tip - Using ESXi Scripted Installation (kickstart) to configure IPv6 networking

Categories // ESXi Tags // alias, cli, esxi, history, shell

Comments

  1. Akram says

    02/20/2015 at 7:56 pm

    Really useful. Was looking for this !!

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • How to disable the Efficiency Cores (E-cores) on an Intel NUC? 03/24/2023
  • Changing the default HTTP(s) Reverse Proxy Ports on ESXi 8.0 03/22/2023
  • NFS Multi-Connections in vSphere 8.0 Update 1 03/20/2023
  • Quick Tip - How to download ESXi ISO image for all releases including patch updates? 03/15/2023
  • SSD with multiple NVMe namespaces for VMware Homelab 03/14/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...