General#
- Get ESXi build and version numbers
vmware -vl
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"