common ESXi CLI commands

As VI admins we can all manage the vSphere client GUI, but sometimes you need to go under the hood to fix things. ESXi operating system consists of the VMkernel and distributed VM filesystem. The VMware vSphere command-line interface (CLI) is the pane of glass used to control the ESXi shell. In this article, I have posted some useful CLI commands for troubleshooting and common operations. I update this page when I find more helpful commands, so I can find them the next time I need them.

Information commands

Check the ESXi hostname:

esxcli system hostname get

Check the version of ESXi installed on the host:

esxcli system version get

Check the ESXi installation time:

esxcli system stats installtime get

Maintenance commands

Put host in maintenance mode:

esxcli system maintenanceMode set --enable yes

Exit maintenance mode:

esxcli system maintenanceMode set --enable no

Shutdown the host:

esxcli system shutdown poweroff

Restart the host:

esxcli system shutdown reboot

Restart ESXi management agents ( ESXi host daemon service) :

/etc/init.d/hostd restart

Restart ESXi management agents (vCenter Agent service) :

/etc/init.d/vpxa restart

Restart all management agents on ESXi :

services.sh restart

Storage commands

List all mappings of VMFS flie system to disks:

esxcli storage vmfs extent list

List all storage devices attached to the host:

esxcli storage core devices list

Network commands

List all physical network interfaces:

esxcli network nic list

List a specific network interface:

esxcli network nic get -n vmnic0

Change link status on physical network interface:

esxcli network nic down -n vmnic0

esxcli network nic up -n vmnic0

VIB installation commands

List all VIB (vSphere installation bundle) packages installed on the host:

esxcli software vib list

List all VIB packages from a specific vendor:

esxcli software vib list | grep vendor_name

Install a VIB package from VMFS volume:

esxcli software vib install -d "/vmfs/volumes/datastore/directoryname/patchname.zip"

Process commands

Check the list of running VMs on the host (displays with VM ID):

esxcli vm process list

Perform a soft shutdown a VM using the VM ID (identified from the previous command):

esxcli vm process kill -w 1234 -t soft

Perform a hard shutdown a VM using the VM ID:

esxcli vm process kill -w 1234 -t hard

Debug/ diagnostic commands

Generate VMware support log bundle( most SRs will require this)

vm-support

Check and troubleshoot ESXi performance with ESXTOP:

esxtop

the ESXTOP output refreshes every 5 seconds, to change the view use the following keys:

  • c – cpu
  • d – disk adaptor
  • i – interrupts
  • m – memory
  • n – network
  • p – power management
  • v – disk VM