Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

ESX common commands

From Tech-Wiki


Legacy ESX/ESXi command reference covering virtual machines, files, hosts, users, networking and storage.

ⓘ
Command availability varies by ESX/ESXi release
This page is being structurally modernised without changing the original command set. Some utilities shown below are associated with older ESX/ESXi administration toolchains, so verify availability on the target host before use.

Virtual machine management

Listing all registered virtual machines

 # vmware-cmd -l

Registering a virtual machine

 # vmware-cmd -s register /vmfs/volumes/storage/VM/MyVM.vmx

VM operations
Possible values: start|stop|reset|suspend hard|soft

 # vmware-cmd -U user -P pass1234 -H VCServer1 -h ESXHost /vmfs/volumes/storage1/MyVMs/VM1.vmx stop soft

Creating a snapshot

 # vmware-cmd -U user -P pass1234 -H VCServer1 -h ESXHost /vmfs/volumes/storage1/MyVMs/VM1.vmx createsnapshot

Relocating a virtual machine's storage (including the disks)

 # svmotion --url=https://myvc.mycorp.com/sdk --datacenter=DC1 --vm="[storage1] myvm/myvm.vmx:new_datastore"

Relocating a virtual machine's configuration file, but leaving the virtual disks

 # svmotion --datacenter='My DC' --vm='[old_datastore] myvm/myvm.vmx:new_datastore' 
 --disks='[old_datastore] myvm/myvm_1.vmdk:old_datastore, [old_datastore] myvm/myvm_2.vmdk:old_datastore'

File management

Creating a virtual disk

 # vmkfstools -c 2048m virtualdisk.vmdk

Creating a VMFS

 # vmkfstools -C vmfs5 -b 1m -S my_test_vmfs /vmfs/devices/disks/test.ID:1

Copying a file to another location

 # vifs -c "[StorageName] VM/VM.vmx" "[StorageName] Backups/VM.vmx"

Listing all the directories

 # vifs --server -D "[StorageName] vms"

Host management

Shutting down a single host

 # vicfg-hostops --operation shutdown --force

Rebooting entire cluster

 # vicfg-hostops --operation reboot --cluster 

Backing up configuration data

 # vicfg-cfgbackup -s /tmp/ESXi_backup.tgz

Restoring configuration data

 # vicfg-cfgbackup -l /tmp/ESXi_backup.tgz

To set up Active Directory, after synchronizing the ESXi host and Active Directory, the following command must be run:

 # vicfg-authconfig --server=  --username=  --password=  --authscheme AD --joindomain   --adusername=   --adpassword=

User management

Listing the existing users

 # vicfg-user -e user -o list

Adding a new user with specified login ID and password

 # vicfg-user -e user -o add -l userx -p password1234

Creating a group

 # vicfg-user -e group -o add -d test

Virtual network management

Listing all virtual switches and associated port groups

 # esxcli network vswitch standard list

Listing all virtual switches and associated port groups

 # vicfg-vswitch -l

Creating a new virtual switch

 # esxcfg-vswitch a TestvSwitch

Adding or removing network cards (known as vmnics) to or from a vNetwork Distributed Switch (vDS)

 # esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch 

Viewing the list of physical adapters and their link status

 # esxcfg-nics l 

Storage management

Listing all logical devices known on the system

 # esxcli storage core device list
OR
 # vicfg-scsidevs --list

Listing all devices, along with corresponding paths, state of the path, adapter type, and other information

 # esxcli storage core path list
OR
 # vicfg-mpath --list-paths

Setting the state of a LUN path to "off"

 # esxcli storage core path set --state off --path vmhba32:C0:T1:L0
OR
 # vicfg-mpath --state off --path vmhba32:C0:T1:L0

Rescanning a storage adapter

 # esxcli storage core adapter rescan --adapter=TestAdapter
OR
 # vicfg-rescan TestAdapter

Enabling or disabling a path

 # esxcfg-mpath -P path -s state 

Checking the ESXi host hardware info

 # esxcfg-info | less i

Filtering out information about a specific system

 # esxcfg-info | grep 'system uuid'

Listing paths to a single device

 # esxcli storage nmp path list --device 

Setting configuration parameters for third-party extensions

 # esxcli storage nmp roundrobin setconfig

iSCSI storage management

Enabling software iSCSI

 # esxcli iscsi software set --enabled=true
OR
 # vicfg-iscsi --swiscsi enable

Adding a new adapter

# esxcli iscsi networkportal add -n -A 

Setting the iSCSI name and alias

 # vicfg-iscsi --iscsiname name

See also