VMware ESXi Command Line Cheat Sheet

Below we list over 120+ common and useful CLI commands (including esxcli) for VMware ESXi Host and VM management. Keep in mind, these shell commands are to be ran at the host CLI, not from the VCSA command line.

Knowing how to work with ESXi CLI commands is an underappreciated skill as a system administrator or infrastructure engineer. Command-line access grants you the ability to configure settings not available in the GUI (of which there are still many), providing greater flexibility in managing your VMware ESXi environment. It significantly enhances your troubleshooting capabilities by allowing you to access detailed system information, logs, and performance metrics quickly. The CLI also enables automation through scripting for handling repetitive tasks, saving you time and streamlining routine maintenance tasks.

Free ESXi CLI Cheat Sheet

Screenshot showing vmware esxi command line cheat sheet preview

Click cheat sheet to view the printable, searchable PDF version.

Feel free to print it out and hang it up or share a link to it with your colleagues and peers.

General

Get ESXi build and version numbers

esxcli system version get

Get host hostname, domain, and FQDN

esxcli system hostname get

Get date and time ESXi was installed

esxcli system stats installtime get

List local users on ESXi host

esxcli system account list

Create local ESXi user

esxcli system account add -d="Description" -i="username" -p="password" -c="password"

List available commands with descriptions

esxcli command getdetails

List all available namespaces with corresponding commands

esxcli esxcli command list

Check maintenance mode

esxcli system maintenanceMode get

Enable/Disable maintenance mode

esxcli system maintenanceMode set –enable true

Reboot/Restart ESXi host

esxcli system shutdown reboot -r "message"

Reboot/Restart ESXi maintenance mode host with countdown timer

esxcli system shutdown reboot -d 10 -r "Patch Updates"

Get CPU information of host (family, model, and cache)

esxcli hardware cpu list

Get memory information (available and non-uniform memory access)

esxcli hardware memory get

Configuration of and information about syslog

esxcli system syslog

Generate support and log information bundle from host

vm-support

Management

Restart Management, HA Services (change to /sbin/services directory)

restart

List Virtual Machines (VMIDs)

vim-cmd vmsvc/getallvms

List running VMs with world ID

esxcli vm process list

Terminate running VM process (forcibly powers off VM)

esxcli vm process kill

Power On

vim-cmd vmsvc/power.on

Power Off (Soft)

vim-cmd vmsvc/power.off

Power Off (Hard)

esxcli vm process kill -w [worldID] -t [soft,hard,force]

Reboot VM

vim-cmd vmsvc/power.reboot

Suspend VM

vim-cmd vmsvc/power.suspend

Resume VM

vim-cmd vmsvc/power.suspendResume

Reset VM

vim-cmd vmsvc/power.reset

Shutdown VM

vim-cmd vmsvc/power.shutdown

Show VM info summary

vim-cmd vmsvc/get.summary

Check Host Performance

esxtop

Check storage I/O performance

vscsiStats

Install Software

Lists currently installed software and drivers (VIBs) on ESXi

esxcli software vib list

Install package (VIB)

esxcli software vib install -v file:/tmp/[NewVIB].vib

Uninstall VIB

esxcli software vib remove -n VIBname

Update installed VIB on ESXi

esxcli software vib update -d “/tmp/update.zip”

Install patch

esxcli software vib install /tmp/[patchName].zip

Virtual Disks

Extend virtual disk

vmkfstools -X 1500G /vmfs/volumes/exampledatastore/Example/Example.vmdk

Rename disk

mv Name.vmdk Name_changed.vmdk

Clone disk

vmkfstools -i Name_changed.vmdk -d zeroedthick Name_changed_clone.vmdk

Remove disk

rm Name.vmdk

Jump to directory of VM and monitor activity of delta, flat, and sesparse files

cd /vmfs/volumes/esxdatastore0/vm/vmfs/volumes/510a4e43-4bf56f05-5a34-0034791e8a3/vm # watch -d 'ls -luth | grep -E "delta|flat|sesparse"'

Delete all snapshots and power off VM. Convert thick provisioned disk to thin disk.

vmkfstools -i /vmfs/volumes/exampledatastore/vm/diskname.vmdk -d thin /vmfs/volumes/exampledatastore/vm/diskname-thin.vmdk

Delete VM thick disk

rm /vmfs/volumes/exampledatastore/vm/diskname-flat.vmdk.thick

Determine configured size of thin disk

ls -lh /vmfs/volumes/exampledatastore/vm/diskname-flat.vmdk

Determine used size of thin disk

du -h /vmfs/volumes/exampledatastore/vm/diskname-flat.vmdk

Snapshots

List all VM snapshots

vim-cmd vmsvc/snapshot.get

Create snapshot for running VM

vmware-cmd vmsvc/snapshot createsnapshot "New Snaphot Name" "Snapshop Description"

Create snapshot for running VM, with RAM

vim-cmd vmsvc/snapshot.create "New Snaphot Name" "Snapshop Description" includeMemory

Delete a snapshot

vim-cmd vmsvc/snapshot.remove

Monitor deleting of snapshot from VM on host

vim-cmd vimsvc/task_list (to get task ID)
vim-cmd vimsvc/task_info <task ID>

Remove all snapshots

vmware-cmd /vmfs/volumes/local0/Example/Example.vmx removesnapshots

Check if volume is native snaphot capable

vmkfstools -Ph /vmfs/volumes/exampledatastore/

Networking

List VM networking information

esxcli network vm list

Get IPv4 configuration for all interfaces on host

esxcli network ip interface ipv4 get

Get firewall state

esxcli network firewall get

Disable firewall

esxcli network firewall set –enabled true | false

Get firewall rules

esxcli network firewall ruleset list

Get firewall rules piped to awk

esxcli network firewall ruleset list | awk '$2 =="true"'

Activate ESXi Firewall Ruleset

esxcli network firewall ruleset set --ruleset-id=sshClient --enabled=true

Specify allowed IP Range for SSH

esxcli network firewall ruleset allowedip add --ruleset-id sshServer --ip-address 10.10.0.0/24

List Kernel Network Interfaces

esxcli network ip interface list

List physical Network Interfaces

esxcli network nic list

Shutdown physical network interface

esxcli network nic down -n

List host routing table

esxcli network ip route ipv4 list

Add static route to esxi host

esxcli network ip route ipv4 add --gateway 10.10.1.1 --network 10.10.0.0/24

Set ESXi host default gateway

esxcfg-route -a default 192.168.254.1

Test ESXi host default gateway

vmkping -D

Send ICMP request

vmkping –I

Test host connectivity to specific port

nc –z

List arp cache

esxcli network ip neighbor list

Clear arp cache entry

esxcli network ip neighbor remove -a -v

List virtual switches

esxcli network vswitch standard list

Change physical uplink of vSwitch

esxcli network vswitch standard uplink remove -u -v
esxcli network vswitch standard uplink add -u -v

List portgroups

esxcli network vswitch standard portgroup list

Add new portgroup to vSwitch

esxcli network vswitch standard portgroup add -p "Portgroup_Name -v

Set Management Network Interface

esxcli network ip interface tag add -i -t Management

Set VLAN id

esxcli network vswitch standard portgroup set --vlan-id -p "Portgroup_Name"

Set SNMP Community

esxcli system snmp set --communities "COMMUNITY_NAME"

Set SNMP Trap destintion

esxcli system snmp set --targets 10.10.1.150/COMMUNITY_NAME

Send test SNMP trap

esxcli system snmp test

Check SNMP State

esxcli system snmp get

Enable IPMI as SNMP source

esxcli system snmp set --hwsrc sensors

Enable CIM as SNMP source

esxcli system snmp set --hwsrc indications

Enable ESXi Host SNMP

esxcli system snmp set --enable true

Capture Network Packets on the a physical interface

pktcap-uw --uplink

List all physical network interfaces

esxcli network nic list

Enable iSCSI software adapter

esxcli iscsi software set –enabled true

Verify iSCSI adapter is enabled

esxcli iscsi software get

List metrics for specific iSCSI adapter

esxcli iscsi adapter param get -A

List established iSCSI sessions

esxcli iscsi sessions

Storage

List current storage devices

esxcli storage core device list

List all storage devices accessible by host

esxcli storage filesystem list

Rename datastore

vim-cmd hostsvc/datastore/rename

List all storage paths

esxcli storage core path list

List storage pathes for specific drive

esxcli storage core path list -d

Generate a list of all LUN paths currently connected to the ESXi host

esxcli storage vmfs extent list

List all storage devices

esxcli storage nmp device list

Get hypervisor filesystem information

vdf

Get usage of hypervisor filesystem

vdu

List all HBAs

esxcfg-scsidevs -a

List all HBAs with WWNN and WWPN

esxcli storage san fc list

Reset HBA and force fabirc logon

esxcli storage san fc reset -A

Check if attached storage LUN supports VAAI

esxcli storage core device vaai status get

Host Services

Enable ESXi shell

vim-cmd hostsvc/enable_esx_shell

Disable ESXi shell

vim-cmd hostsvc/disable_esx_shell

Start ESXi shell

vim-cmd hostsvc/start_esx_shell

Enable the SSH daemon

vim-cmd hostsvc/enable_ssh

Disable SSH daemon

vim-cmd hostsvc/disable_ssh

Start SSH daemon

vim-cmd hostsvc/start_ssh

Enter Maintenance mode

vim-cmd hostsvc/maintenance_mode_enter

Exit Maintenance Mode

vim-cmd hostsvc/maintenance_mode_exit

ESXi Kernel modules

List loaded kernel modules

vmkload_mod -l

List kernel interfaces

esxcfg-vmknic -l

Utility for capturing VMkernel events

vmkeventd

Utility for logging VMkernel events

vmklogger

Display physical adapters with link state and MAC addresses

esxcfg-nics -l
esxcfg-vswitch -l
esxcfg-vmknic -l

Create Kernel interface with specfic MAC and IP Address and add it to portgroup

esxcfg-vmknic -a -i 10.10.1.2 -n 255.255.254.0 -M 00:11:22:aa:bb:cc -p
esxcfg-vmknic -p -e true

Delete Kernel interface

esxcfg-vmknic -d -p

List all enabled kernel modules

esxcfg-module -q

Get parameters of a kernel modul, i.e. an Emulex FC HBA module

esxcfg-module -g

Set kernel module parameters

esxcfg-module -s "lpfc0_lun_queue_depth=8 lpfc1_lun_queue_depth=8 lpfc2_lun_queue_depth=8 lpfc3_lun_queue_depth=8"

Show all kernel module information

esxcfg-module -i

List Advanced Kernel Settings/Parameters

esxcli system settings advanced list -d

Set Advanced Kernel Parameter

esxcli system settings advanced set -o /UserVars/ExampleKernelParameter -i 0

Add Kernel interface to portgroup

esxcfg-vmknic –a -i -n "Portgroup_Name"

How to Access the CLI in ESXi

There are two primary ways to access the ESXi shell, the Direct Console User Interface (DCUI) on the host itself and via SSH, which needs to be enabled before it can be used.

Direct Console User Interface (DCUI):

  1. Connect directly to your ESXi host from the physical server’s console.
  2. Press F2 to access the System Customization menu.
  3. In the DCUI, go to “Troubleshooting Options“, navigate to “Enable ESXi Shell” and/or “Enable SSH“, and press Enter to enable each desired service.
  4. Press “Alt + F1” to open the command line console. You’ll need to enter your login credentials (root user credentials can be used).
  5. To go back to the DCUI, press “Alt + F2“.

Using VMware Host Interface to Enable SSH:

  1. Open a web browser, enter the IP address of your ESXi host in the address bar, and log in.
  2. Navigate to “Host” > “Actions” > “Services“, and click “Enable Secure Shell (SSH)“.
  3. You can now connect to the ESXi console remotely using an SSH client.

Using vCenter and VMware vSphere Interface to Enable SSH:

This method is used only if your ESXi host is managed by vCenter Server.

  1. In the VMware HTML5 vSphere Client, go to “Hosts and Clusters“, select your ESXi host, select the “Configure” tab, open “System” > “Services“, and click “SSH” in the list of services.
  2. Click “Start” to launch the SSH server once, or “Edit Startup Policy” and select “Start and Stop with host” if you wish to enable the SSH server for an extended period. You can also enable the ESXi shell in the “Services” menu.

Using Remote Access via SSH:

After enabling SSH via one of the above methods, you can access the ESXi CLI remotely using an SSH client.

For Linux and Apple users, you can use the command ‘ssh yourESXiIPaddress‘ in your terminal. Replace ‘yourESXiIPaddress‘ with the actual IP address of your ESXi host.

For Windows users, a free SSH client like PuTTY can be used to connect to your ESXi host. You can also use Command Prompt or PowerShell provided you’re on Windows 10 (1709 or later) or Windows 11. Just like Linux and Apple users, the command is simply ‘ssh yourESXiIPaddress‘.

Recommended Tool: ManageEngine OpManager

  • Multi-vendor Network Monitoring
  • Simple Installation & Setup
  • Intuitive UI
  • Complete Visibility
  • Intelligent Detections
  • Easy Resolutions

3 Comments

  1. Unbelievable work, thank you so much sharing on Internet!

  2. Avatar Gonçalo Martins says:

    Please correct:
    Show VM info summary
    vim-cmd vmsvc/power.shutdown

    to

    vim-cmd vmsvc/get.summary

    Congratulations for this great cheat sheet.

    1. Avatar Chase Smith, CCNP says:

      Yikes! Thanks for catching that! The post and pdf have been updated.

Leave a Reply

Your email address will not be published. Required fields are marked *