This is a quick and dirty cheatsheet for VMware ESXi server version 7, many commands can be used on the older version.
General
Check ESXi build and version numbers
esxcli system version get
Get the hostname, domain and FQDN for the host
esxcli system hostname get
Get the date and time when ESXi was installed
esxcli system stats installtime get
List the local users created on the ESXi host
esxcli system account list
Create local ESXi users
esxcli system account add -d="Guest User" -i="guest" -p="user123!" -c="user123!"
Description of all the esxcli commands on this system
esxcli command getdetails
Lists all the available namespaces and corresponding commands
esxcli esxcli command list
Check maintenance mode
esxcli system maintenanceMode get
Enable/Disable maintenance mode
esxcli system maintenanceMode set –enable true
Reboot ESXi host
esxcli system shutdown reboot -r "message"
Reboot ESXi host (that is in maintenance) with a countdown timer
esxcli system shutdown reboot -d 10 -r "Patch Updates"
Retrieve CPU information (family, model and cache) of your ESXi host
esxcli hardware cpu list
Retrieve information about memory (available and non-uniform memory access)
esxcli hardware memory get
Syslog information and configuration
esxcli system syslog
Grab a complete bundle of all the support and log information that you have inside a ESXi host
vm-support
Management
Restart Management, HA Services
/sbin/services restart
Get a list of all Virtual Machines (VMIDs)
vim-cmd vmsvc/getallvms
List all the running VMs on the hosts and get the world ID of the virtual machines
esxcli vm process list
Terminate running VM process, essentially shutting down or forcibly powering off a VM
esxcli vm process kill
Power On
vim-cmd vmsvc/power.on 36
Power Off (Soft)
vim-cmd vmsvc/power.off 36
Power Off (Hard)
esxcli vm process kill -w [worldID] -t [soft,hard,force]
Reboot a virtual machine
vim-cmd vmsvc/power.reboot 36
Suspend a virtual machine
vim-cmd vmsvc/power.suspend
Resume a virtual machine
vim-cmd vmsvc/power.suspendResume
Reset a virtual machine
vim-cmd vmsvc/power.reset
Shutdown a virtual machine
vim-cmd vmsvc/power.shutdown
Show VM summary infomation
vim-cmd vmsvc/power.shutdown
Check Performance (top like Linux)
esxtop
Check performance of storage I/O
vscsiStats
Install Software
Lists all the currently installed software and drivers (VIBs) on ESXi
esxcli software vib list
Install a package (VIB)
esxcli software vib install -v file:/tmp/[NewVIB].vib
Uninstall a VIB
esxcli software vib remove -n VIBname
Update an installed VIB on ESXi
esxcli software vib update -d “/tmp/update.zip”
Install a patch
esxcli software vib install /tmp/[patchName].zip
Virtual Disks
Extend a virtual disk, i.e. to 500GB
vmkfstools -X 4500G /vmfs/volumes/datastore1/Test/test.vmdk
Rename Workstation disk
mv Computer.vmdk Computer_WS.vmdk
Clone Workstation disk
vmkfstools -i Computer_WS.vmdk -d zeroedthick Computer.vmdk
Remove Workstation disk
rm Computer_WS.vmdk
Jump to the directory of the VM and monitor the activity of the sesparse, delta and flat files
cd /vmfs/volumes/esxdatastore0/vm
/vmfs/volumes/510a4e43-4bf56f05-5a34-0034791e8a3/vm # watch -d 'ls -luth | grep -E "delta|flat|sesparse"'
Convert VMs a thick provisioning disk to a thin disk. Delete all snapshots and Power off your virtual machine
vmkfstools -i /vmfs/volumes/esxdatastore0/vm/vmdisk.vmdk -d thin /vmfs/volumes/esxdatastore0/vm/vmdisk-flat-thin.vmdk
Delete the thick disk of a VM
rm /vmfs/volumes/esxdatastore0/vm/vmdisk-flat.vmdk.thick
Determine the configured size of a thin disk
ls -lh /vmfs/volumes/esxdatastore0/vm/vmdisk-flat.vmdk
Determine the used size of a thin disk
du -h /vmfs/volumes/esxdatastore0/vm/vmdisk-flat.vmdk
Snapshots
List all snapshots for a virtual machine
vim-cmd vmsvc/snapshot.get 36
Create a snapshot for a VM thats running
vmware-cmd vmsvc/snapshot createsnapshot "New Snap" "Snap desc" 1 1
Create a snapshot for a VM, including the RAM of the Machine
vim-cmd vmsvc/snapshot.create 36 "New Snap" "Snap desc" includeMemory
Delete a snapshot, where 36 is the VMID and 2 the Snapshot ID
vim-cmd vmsvc/snapshot.remove 36 2
Monitor deleting of Snapshots. Login to the host where the VM resides.
vim-cmd vimsvc/task_list
vim-cmd vimsvc/task_info haTask-32-vim.VirtualMachine.removeAllSnapshots-140465256
Remove all snapshots
vmware-cmd path-to/vmx-file removesnapshots
Check if a volume supports native respectively hardware snapshots
vmkfstools -Ph /vmfs/volumes/esxdatastore0/
Network
List networking information about VMs that have an active network port
esxcli network vm list
Displays the IPv4 configuration for all the interfaces present on ESXi
esxcli network ip interface ipv4 get
Firewall state
esxcli network firewall get
Disable firewall (not recommended)
esxcli network firewall set –enabled true | false
Firewall rules
esxcli network firewall ruleset list
Firewall rules piped to awk
esxcli network firewall ruleset list | awk '$2 =="true"'
Firewall activate a ruleset
esxcli network firewall ruleset set --ruleset-id=sshClient --enabled=true
Only allow an IP Range for the 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 vmnic4
List routing table
esxcli network ip route ipv4 list
Add a route
esxcli network ip route ipv4 add --gateway 10.10.0.254 --network 10.10.0.0/24
Set Default Gateway
esxcfg-route -a default 192.168.254.1
Test Default Gateway
vmkping -D
send ICMP request to 10.10.10.1 through vmk1 interface
vmkping –I vmk1 10.10.10.1
Test connectivity to 10.10.10.10 on port 3260
nc –z 10.10.10.10 3260
List arp cache
esxcli network ip neighbor list
Remove arp cache entry
esxcli network ip neighbor remove -a 10.10.0.3 -v 4
List all virtual switches
esxcli network vswitch standard list
Change the physical uplink of an vSwitch
esxcli network vswitch standard uplink remove -u vmnic0 -v vSwitch1
esxcli network vswitch standard uplink add -u vmnic1 -v vSwitch1
List all portgroups
esxcli network vswitch standard portgroup list
Add a new portgroup at the vSwitch to which the Kernel Interface should connect
esxcli network vswitch standard portgroup add -p "PG MEGA" -v vSwitch0
Set Interface as Management Network
esxcli network ip interface tag add -i vmk0 -t Management
Set the VLAN id
esxcli network vswitch standard portgroup set --vlan-id 0 -p "PG MEGA"
Set Community
esxcli system snmp set --communities MEGA
Set Trap destintion
esxcli system snmp set --targets 192.168.254.100/MEGA
Send test trap
esxcli system snmp test
Check 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 SNMP
esxcli system snmp set --enable true
Capture Network Packets on the a physical interface
pktcap-uw --uplink vmnic0
List all physical nic’s
esxcli network nic list
Enables the iSCSI software adapter and verify that the iSCSI adapter is enabled
esxcli iscsi software set –enabled true && esxcli iscsi software get
Return metrics for the specified iSCSI adapter
esxcli iscsi adapter param get -A vmhba65
Return established iSCSI sessions on the host
esxcli iscsi sessions
Storage
List the current storage devices
esxcli storage core device list
Get a list of all storage devices (volumes or datastores) accessible by the ESXi host
esxcli storage filesystem list
Rename a datastore
vim-cmd hostsvc/datastore/rename OldName NewName
Get a list of all storage pathes
esxcli storage core path list
Get storage pathes for a specific drive
esxcli storage core path list -d naa.600000e00d11000000111a2400000000
Generate a list of extents for each volume as well as the corresponding device name to UUID mapping
esxcli storage vmfs extent list
Show Storage Array Type and Path selection policies of disk devices
esxcli storage nmp device list
Set Roundrobin(VMW_PSP_RR) path selection policy for a disk device, possible other policies are “Most recently used”:VMW_PSP_MRU or “Fixed”:VMW_PSP_FIXED
esxcli storage nmp device set -P VMW_PSP_RR -d naa.600000e00d11000000111a2400020000
Stat of the visorfs (Hypervisor Filesystem)
vdf
Usage of the visorfs (Hypervisor Filesystem)
vdu
List all HBAs
esxcfg-scsidevs -a
List all HBAs with the corresponding WWNN and WWPN
esxcli storage san fc list
Reset a HBA and force an fabirc logon
esxcli storage san fc reset -A vmhba3
Check if a storage LUN attached to an ESXi 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
A utility for capturing VMkernel events
vmkeventd
A utility for logging VMkernel events
vmklogger
Checking physical MAC addresses
esxcfg-nics -l
esxcfg-vswitch -l
esxcfg-vmknic -l
Create a n Kernel interface with a specfic MAC and IP Address and add it to a portgroup
esxcfg-vmknic -a -i 192.168.254.3 -n 255.255.255.0 -M 01:12:34:56:78:90 -p PortGroupName
esxcfg-vmknic -p PortGroupName -6 false
Delete an Kernel interface
esxcfg-vmknic -d -p PortGroupName
Get a list of all enabled kernel modules
esxcfg-module -q
Get parameters of a kernel modul, i.e. an Emulex FC HBA module
esxcfg-module -g lpfc820
lpfc820 enabled = 1 options = 'lpfc0_lun_queue_depth=8 lpfc1_lun_queue_depth=8 lpfc2_lun_queue_depth=8 lpfc3_lun_queue_depth=8'
Set kernel module parameters, also i.e. the Emulex FC HBA module
esxcfg-module -s "lpfc0_lun_queue_depth=8 lpfc1_lun_queue_depth=8 lpfc2_lun_queue_depth=8 lpfc3_lun_queue_depth=8" lpfc820
Get info of a module with all possible parameters and a description of each
esxcfg-module -i lpfc820
Get all ESXi Advanced Kernel Settings/Parameters
esxcli system settings advanced list -d
Set one Advanced Kernel Parameter, i.e. disable the shell SSH warnings
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1
Add a Kernel interface to a Portgroup
esxcfg-vmknic –a -i 192.168.254.5 -n 255.255.255.0 "PG MEGA"
Multipathing
Detailed information
esxcfg-mpath -l
List all Paths with abbreviated information
esxcfg-mpath -L
List all Paths with adapter and device mappings
esxcfg-mpath -m
List all devices with their corresponding paths
esxcfg-mpath -b
List all Multipathing Plugins loaded into the system
esxcfg-mpath -G
Set the state for a specific LUN Path. Requires path UID or path Runtime Name in –path
esxcfg-mpath --state <active|off>
Specify a path for operations
esxcfg-mpath -P
Filter the list commands to display only a specific device
esxcfg-mpath -d
Restore path setting to configured values on system start
esxcfg-mpath -r
We need your help!
Do you know a command that we haven’t included in this VMware ESXi CheatSheet?
Help us keep the VMware ESXi CheatSheet up-to-date and enrich it by sharing the VMware ESXi commands that you know with other system administrators.