Random ESXi 5 CLI Tips and Shortcuts #1

I’ve started this post as a way to track any ESXi CLI tips, tricks/shortcuts that I think may be useful for the VCAP-DCA exam, though should also be of use generally. Thought  I haven’t yet taken the exam myself (though will be shortly!), a lot of the posts written by those that have taken the exam highlight the fact that time management is a big issue. With this in mind, I starting thinking about ways to find things quickly using the available tools. This post is the result of some of the things I think may be useful,  and there will likely be further post in time – if there are any tips/shortcuts you use please let me know in the comments section! I’ll start by looking at using ‘grep’ to help find ESXi advanced settings quickly.

Using grep to find ESXi Advanced Settings

I think there will be a lot of focus on ESXi host advanced settings on the VCAP-DCA exam. You can list all the advanced settings using esxli by running:

~ # esxcli system  settings advanced list

The output for this will fill many pages so I tend to pipe it to the less command:

~ # esxcli system  settings advanced list | less

Once in ‘less’ you can search the output, for example by typeing ‘/mem’. Another way to search the output is to use the ‘grep’ command. For example, running the following will find all entries in the output that contain ‘mem’:

~ # esxcli system  settings advanced list | grep -i mem

To be more specific we can search for lines that include both ‘Path’ and ‘mem’, which will display all the settings that include ‘mem’:

~ # esxcli system  settings advanced list | grep -i -e 'Path.*mem'
   Path: /Mem/UseLowMemFirst
   Path: /Mem/UseStressLowMemory
   Path: /Mem/BalancePeriod
   Path: /Mem/SamplePeriod
   Path: /Mem/SampleMapLargeThreshold
   Path: /Mem/IdleTax
   Path: /Mem/IdleTaxType

To include the full description and other parameter values, add ‘-A 9’ to the command, which will show the 9 lines that follow the matched pattern. For example:

~ # esxcli system  settings advanced list | grep -i -e 'Path.*mem' -A 9
   Path: /Mem/UseLowMemFirst
   Type: integer
   Int Value: 0
   Default Int Value: 0
   Min Value: 0
   Max Value: 1
   String Value:
   Default String Value:
   Valid Characters:
   Description: Preferred use of low memory if no type is specified

Alternatively, you could search the description line then display the previous 9 lines in order to get the setting path:

~ # esxcli system  settings advanced list | grep -i -e 'Description.*compression' -B 9 
   Path: /Mem/MemZipEnable
   Type: integer
   Int Value: 1
   Default Int Value: 1
   Min Value: 0
   Max Value: 1
   String Value:
   Default String Value:
   Valid Characters:
   Description: Enable the memory compression cache

Finding ESXCLI commands using grep

Grep is a great tool, and along with helping to find advanced settings as shown in the examples above, you can also use it to help find esxcli commands. For example, you know that there are some snmp related commands available in esxcli, but can’t remember exactly where the namespace is in the hierarchy? Run:


~ # esxcli esxcli command list | grep snmp
system.snmp                                             get
system.snmp                                             hash
system.snmp                                             set
system.snmp                                             test

From the output, it is clear that the snmp commands can be found under the system namespace:


~ # esxcli system
Usage: esxcli system {cmd} [cmd options]

Available Namespaces:
  boot                  Operations relating to host boot that allow manipulation of VMkernel boot time configuration.
  coredump              Operations pertaining to the VMkernel Core dump configuration.
  module                Operations that allow manipulation of the VMkernel loadable modules and device drivers. Operations include load, list and setting options.
  process               Commands relating to running processes.
  secpolicy             Options related to VMkernel access control subsystem. These options are typically in place for specific workarounds or debugging. These commands should be used at the direction of VMware
                        Support Engineers.
  settings              Operations that allow viewing and manipulation of system settings.
  stats                 Access to various system statistics
  syslog                Operations relating to system logging
  visorfs               Operations pertaining to the visorfs memory filesytem.
  hostname              Operations pertaining the network name of the ESX host.
  maintenanceMode       Command to manage the system's maintenance mode.
  shutdown              Command to shutdown the system.
  snmp                  Commands pertaining to SNMPv1/v2c/v3 Agent configuration.
  time                  Commands to get and set system time.
  uuid                  Get the system UUID
  version               Commands to get version information.
  welcomemsg            Commands to get and set the welcome banner for DCUI.

Related posts

VMware vSphere Virtual Machine Snapshots Explained

Understanding Type 1 and Type 2 Hypervisors

How to Enable SSH on All ESXi Hosts using PowerCLI

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More