Context & Why You Need esxcli in ESXi Administration
The Web UI or vCenter is great for day-to-day operations. But when disaster strikes, graphical interfaces often freeze or become completely unresponsive. A dropped network adapter leaves the web UI unreachable, a locked .vmx file prevents a VM from shutting down, or vCenter loses connectivity to the ESXi host. In those moments, SSHing directly into the host is your only lifeline.
At home, I run a 12-VM Proxmox VE homelab for quick testing. But at work, our production infrastructure sits on an 8-node Dell PowerEdge cluster running VMware ESXi 7.0, powering over 250 critical business VMs. After many late-night troubleshooting sessions at 2 AM, esxcli has saved our team from some truly memorable downtime incidents.
Unlike disjointed Linux commands, VMware structured esxcli into a well-defined namespace hierarchy: esxcli <namespace> <object> <action>. Once you master this syntax, you can interact directly with hardware, storage, or virtual networking without relying on vCenter.
Setup & Enabling the esxcli Environment
For security reasons, ESXi disables SSH by default. To use the command line, you need to enable it via the Direct Console User Interface (DCUI) or the web client.
Enabling SSH Directly via the DCUI Console
When the web client is completely unreachable, connect directly with a monitor and keyboard or open a remote console session via iLO (HPE) or iDRAC (Dell):
- Press F2 and enter the ESXi root password.
- Navigate down to Troubleshooting Options.
- Select Enable SSH and press Enter.
Access and Overview of esxcli Syntax
Once logged in as root, you can immediately run:
esxcli --help
The four namespaces you will encounter most frequently:
hardware: inspect CPU, RAM, motherboard details, and PCI buses.network: manage vSwitches, port groups, VMkernel IPs, and physical NICs.storage: check VMFS volumes, iSCSI/FC LUNs, and disks.vm: trace and manage frozen virtual machine processes.
In-Depth Configuration: VMkernel Networking, Hardware, and VM Recovery
1. Managing Hardware and Physical Network Adapters (vmnic)
Sometimes a 10GbE NIC negotiates down to 1Gbps, or switch duplex mismatches cause intermittent packet drops. The network nic command set helps you diagnose these issues:
# List all physical NICs (vmnic) and their current link speeds
esxcli network nic list
# View detailed model, driver, and firmware information for vmnic0
esxcli network nic get -n vmnic0
# Force 10Gbps Full Duplex when switch auto-negotiation fails
esxcli network nic set -n vmnic0 --speed 10000 --duplex full --auto false
When you need the Service Tag for warranty support or want to check PSU fan status:
# Retrieve serial number / Service Tag and physical server model
esxcli hardware platform get
# Read temperature and power sensor metrics via IPMI
esxcli hardware ipmi sensor list
2. Creating and Configuring VMkernel Ports (vmk)
VMkernel ports handle critical infrastructure traffic: management IPs, vMotion, and iSCSI/NFS storage connections. If someone accidentally deletes the management IP or the existing network gets isolated, you can spin up an emergency rescue port group on vSwitch0:
# Create a new port group named Rescue-Mgmt on vSwitch0
esxcli network vswitch standard portgroup add --portgroup-name="Rescue-Mgmt" --vswitch-name="vSwitch0"
# Assign VLAN 10 to the newly created port group
esxcli network vswitch standard portgroup set --portgroup-name="Rescue-Mgmt" --vlan-id=10
# Create VMkernel interface vmk1 attached to this port group
esxcli network ip interface add --interface-name=vmk1 --portgroup-name="Rescue-Mgmt"
# Assign static IP 192.168.10.50/24 to vmk1 to regain access
esxcli network ip interface ipv4 set --interface-name=vmk1 --ipv4=192.168.10.50 --netmask=255.255.255.0 --type=static
3. Rescuing Frozen Virtual Machines (Kill Unresponsive VM)
A common scenario: A 2TB database VM encounters a storage I/O lockup, and the guest OS freezes completely. Clicking Power Off in vCenter simply results in a timeout error after 15 minutes. Instead of rebooting the entire physical host and impacting dozens of other VMs, you can terminate that specific VM process directly:
# Step 1: List running VMs to obtain the World ID
esxcli vm process list
# Step 2: Locate the problematic VM and note its World ID (e.g., 1245678)
# Attempt a graceful shutdown first (Soft kill) so the OS can close files if still responsive
esxcli vm process kill --type=soft --world-id=1245678
# Step 3: If the VM remains unresponsive after 20-30 seconds, escalate to Hard kill
esxcli vm process kill --type=hard --world-id=1245678
# Step 4: Final resort when the process is deeply stuck in the kernel (Force kill)
esxcli vm process kill --type=force --world-id=1245678
The force option immediately releases file locks on the .vmx and -flat.vmdk files. This allows you to power the VM back on right away without rebooting the physical host.
Verifying & Monitoring the System from the Command Line
Once the issue is resolved, do not close the terminal just yet. Verify all network connections and routes first.
Checking the Routing Table and VMkernel Network Connectivity
The standard ping command follows the general routing table. To accurately test specific VMkernel interfaces dedicated to vMotion or NFS storage, you must use vmkping with the -I flag:
# Ping the gateway via interface vmk1
vmkping -I vmk1 192.168.10.1
# Test Jumbo Frames (MTU 9000) with fragmentation disabled (-d) to SAN storage (8972-byte payload + 28-byte ICMP header)
vmkping -I vmk1 -d -s 8972 192.168.10.100
# View current ESXi host IPv4 routing table
esxcli network ip route ipv4 list
Real-Time Performance and I/O Monitoring
When you suspect a specific VM is saturating storage I/O or hogging CPU, esxtop is the most insightful real-time monitoring tool available:
# Launch real-time performance monitor
esxtop
Inside the esxtop interface, press d to inspect disk latency, n to view network traffic, or m to inspect memory utilization. Pay close attention to two metrics: DAVG/cmd (device-level latency) and KAVG/cmd (ESXi kernel latency). If either of these values consistently exceeds 20ms, your storage subsystem is experiencing a significant bottleneck.
Mastering these essential esxcli commands ensures you stay in full control of your ESXi hosts even during a total vCenter outage. Often, just two or three minutes of targeted SSH commands can bring your system back to life, sparing you from rebooting an entire server cluster in the middle of the night.

