Guide
ESXi command line: a cheat sheet of esxcli and vim-cmd commands
ESXi's command line has two tools that do nearly everything: esxcli for the host (storage, network, software, maintenance mode) and vim-cmd for virtual machines (list, power, snapshots). Turn on SSH in the Host Client, sign in as root, and they're there.
Below is a cheat sheet of the commands worth knowing on ESXi 7 and 8, grouped by job. For setting up and running an ESXi host day to day, see how to manage a VMware ESXi host remotely.
- Turn on SSH first
- esxcli for the host
- vim-cmd for VMs
Updated · VMware ESXi 7 and 8
Turn on SSH and the ESXi Shell
Step 1: From the Host Client
Sign in to the Host Client, the host's own web page, and click Host in the navigator. Then choose Actions > Services > Enable Secure Shell (SSH). Enable console shell turns on the shell on the server's own screen as well.
Step 2: Or at the server's console
On the yellow and grey console screen, press F2, sign in, open Troubleshooting Options and choose Enable SSH. With the console shell on, Alt+F1 opens it on that screen.
Step 3: Sign in
From PowerShell, a Mac or Linux terminal:
ssh root@esxi-01. If SSH is already on and you just need to start it again later,vim-cmd hostsvc/enable_sshandvim-cmd hostsvc/start_sshdo it from the shell.
Turn it off when you're done
Virtual machines (vim-cmd)
Most VM commands take the VM's Vmid, the number getallvms shows in its first column (2 in these examples).
vim-cmd vmsvc/getallvms # every registered VM with its Vmid vim-cmd vmsvc/power.getstate 2 # Powered on / Powered off vim-cmd vmsvc/power.on 2 vim-cmd vmsvc/power.shutdown 2 # clean shutdown from the guest (needs VMware Tools) vim-cmd vmsvc/power.reboot 2 # clean restart from the guest (needs VMware Tools) vim-cmd vmsvc/power.off 2 # pull the plug vim-cmd vmsvc/get.guest 2 # guest details, including its IP address esxcli vm process list # running VMs with their World ID esxcli vm process kill --type=soft --world-id=1234567 # a stuck VM; then hard, then force
Snapshots, registering and copying disks
vim-cmd vmsvc/snapshot.get 2 vim-cmd vmsvc/snapshot.create 2 "before-update" "patch night" 0 0 vim-cmd vmsvc/snapshot.removeall 2 # delete (consolidate) all of its snapshots vim-cmd solo/registervm /vmfs/volumes/datastore1/dns-02/dns-02.vmx vim-cmd vmsvc/unregister 2 # removes it from the list, keeps its files vmkfstools -i /vmfs/volumes/datastore1/dns-01/dns-01.vmdk /vmfs/volumes/datastore1/dns-02/dns-02.vmdk -d thin
In snapshot.create, the two zeros mean "don't include the memory" and "don't quiesce". The vmkfstools -i line copies a virtual disk as thin-provisioned, the usual first step of cloning a VM by hand on a host without vCenter.
The host: version, hardware and maintenance mode
esxcli system version get esxcli system hostname get esxcli hardware platform get esxcli hardware memory get esxcli software vib list # installed packages and drivers esxcli system maintenanceMode set --enable true esxcli system maintenanceMode get esxcli system shutdown reboot -r "BIOS update" # needs maintenance mode esxcli system maintenanceMode set --enable false
A host only enters maintenance mode once its VMs are off (or moved, with vCenter), so shut them down first.
Storage
esxcli storage filesystem list # datastores, size and free space df -h ls /vmfs/volumes/datastore1/ esxcli storage core device list # disks the host can see esxcli storage core adapter rescan --all
Network
esxcli network nic list # physical NICs, link and speed esxcli network ip interface ipv4 get # the host's own addresses esxcli network vswitch standard list esxcli network ip dns server list vmkping -I vmk0 nas-01 # ping from the host's management interface
Services and logs
/etc/init.d/hostd restart # the host's management agent, if the Host Client stops answering /etc/init.d/vpxa restart # the vCenter agent, on hosts managed by vCenter tail -f /var/log/hostd.log tail -f /var/log/vmkernel.log
Restarting hostd doesn't touch running VMs, but the Host Client and any vCenter connection drop for a minute.
Run these from RemoteAccessApp
Save the host in the RemoteAccessApp SSH client as an SSH host with a key or password, and the shell opens in a tab. Put the checks you run often in the terminal's Scripts & History panel, and run one on all your ESXi hosts at once with Run on hosts…, which shows each host's output and result. Stick to commands ESXi's shell has: it's a small shell, and many Linux tools aren't there.
Hosts on your home or office network can be reached through one of your own PCs there, so neither SSH nor the Host Client has to face the internet. Free on Windows and Linux for up to 5 saved hosts: download RemoteAccessApp. New to running a lab? Start with how to set up a homelab, and see the SSH client checklist for what to look for in an SSH app.
Questions, answered
More homelab and virtualization guides
- Manage Proxmox, VMware & KVM hostsSSH, web interfaces, RDP and VNC consoles, ISO and backup copies, scripts and dashboards for your hypervisor hosts and VMs, in one app.Read the guide
- Homelab managementOne app for a homelab: SSH, SFTP and FTP, RDP and VNC, web panels, a live host dashboard, and remote desktop for Windows and Linux PCs.Learn more
- Proxmox VE remote managementSSH to Proxmox VE nodes with keys, reach the web UI without opening ports, run qm and pct across nodes, and move ISOs and backups.Read the guide
- Manage VMware ESXi remotelyThe ESXi Host Client and vSphere Client in a tab, SSH with esxcli and vim-cmd, datastore files, and RDP or SSH into guests.Read the guide
- KVM and QEMU VM consoleslibvirt VNC consoles through an SSH tunnel, virsh for everything else, and honest limits for SPICE displays.Read the guide
- Manage Hyper-V remotelyRemote desktop and PowerShell on Hyper-V hosts, RDP into Windows guests, and the same command on many hosts.Read the guide
- TrueNAS, Unraid and NAS accessYour NAS web UI as a saved panel, SSH and SFTP with keys, a live dashboard and server-to-server copies.Read the guide
- pfSense, OPNsense and router adminKeep firewall and router admin pages off the internet and still reach them: web panels, a PC on the LAN, SSH and serial consoles.Read the guide
- Docker and Podman hostsContainers, logs, restarts and shells over SSH, host dashboards, and scripts across every Docker or Podman host.Read the guide
- Raspberry Pi and small serversSSH into a Pi, see its desktop over VNC inside SSH, copy files and reach it from outside your home, from one app or a browser.Read the guide
- Dell iDRAC remote accessReach the iDRAC's web page and virtual console on your network or from anywhere, configure it with racadm, and fix a connection that won't open.Read the guide
- HPE iLO remote consoleiLO and its HTML5 console in a tab, power and the virtual serial port over SSH, and a private way in from anywhere.Read the guide
- Supermicro IPMI and iKVMThe BMC page and HTML5 iKVM in a tab, ipmitool from a server on the same network, and IPMI kept off the internet.Read the guide
- One app for your whole homelabWhy juggling terminals, browser tabs and viewers for a homelab gets old, and what one app for every host and VM looks like.Read the post
- Homelab maintenance checklistUpdates, backups, disk checks and consoles: a maintenance-night checklist for a homelab, worked through from one window.Read the post
- Stop exposing your hypervisor web UIWhy management web UIs belong on your own network, and how to reach them from anywhere without opening a port.Read the post
- 5 workflows for many serversGroups and tags, saved workspaces, one script on many hosts, direct server-to-server copies and live dashboards.Read the post
- What is IPMI?IPMI and the BMC explained: what a homelab uses them for, the ipmitool commands worth knowing, and how to reach IPMI without putting it online.Read the guide
- Homelab setupStart a homelab without overbuying: one machine, a hypervisor, a few services, backups, and a safe way to reach it from anywhere.Read the guide
