Monday, September 29, 2014

VMware ESXi SSH CLI basic commands

vim-cmd vmsvc/getallvms

Lists all vm's running on hypervisor and provides vmid

vim-cmd vmsvc/power.off vmid
Powers off vmid referenced from getallvms command

vim-cmd vmsvc/power.on vmid
Powers off vmid referenced from getallvms command

vim-cmd vmsvc/power.reboot vmid
Reboots vmid referenced from getallvms command

vim-cmd vmsvc/destroy vmid
Deletes the vmdk and vmx files from disk

vim-cmd hostsvc/maintenance_mode_enter
Puts hypervisor into maintenance mode

vim-cmd hostsvc/maintenance_mode_exit
Takes hypervisor out of maintenance mode

vim-cmd solo/registervm /vmfs/vol/datastore/dir/vm.vmx
Registers vm in hypervisor inventory

vim-cmd vmsvc/unregister vmid
Unregisters vm with hypervisor

vim-cmd vmsvc/tools.install vmid
Starts vmware tools installation for VM

vim-cmd hostsvc/net/info
Provides information about hypervisor networking

chkconfig -l
Shows daemons running on hypervisor. Can also be used for configuration.

esxtop
Same as linux top for vmware

vmkerrcode -l
List of vmkernel errors

esxcfg-info
Lists a LOT of information about the esx host

esxcfg-nics -l
Lists information about NIC's. Can also be used for configuration.

esxcfg-vswitch -l
Lists information about virtual switching. Can also be used for configuration.

dcui
Provides console screen to ssh session

vsish
Vmware interactive shell
------------------------------------
Update Patches or ESXI upgrade through Command Line

#vim-cmd hostsvc/maintenance_mode_enter 
#esxcli software vib install -d "/vmfs/volumes/datastore1/patch-directory/ESXi500-201111001.zip" 
#esxcli software vib install -v     https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/esx/vmw/vib20/tools-light/VMware_locker_tools-light_5.0.0-0.7.515841.vib 

###Verify that the VIBs are installed on your ESXi host:
#esxcli software vib list 

After the patch has been installed, reboot the ESX host:

# reboot 

After the host has finished booting, exit maintenance mode and power on the virtual machines:

# vim-cmd hostsvc/maintenance_mode_exit
===========================================================================
Below is a list of most common CLI commands for VMWare ESXi. Type these in directly in an ESXi or SSH shell.
vim-cmd vmsvc/getallvmsList all VMs running on the host. Also provides vmid, required for commands below.
vim-cmd vmsvc/power.off vmidPower off specified VM.
vim-cmd vmsvc/power.on vmidPower off specified VM.
vim-cmd vmsvc/power.reboot vmidReboot specified VM.
vim-cmd solo/registervm /vmfs/volume/datastore/subdir/vm-file.vmxRegister the VM stored at location on the ESX host inventory.
vim-cmd vmsvc/unregister vmidUnregister VM from the host. Does not remove the VM's files from the datastore.
vim-cmd vmsvc/destroy vmidDelete the specified VM. The VMDK and VMX files will be deleted from storage as well.
vim-cmd vmsvc/tools.install vmidInitiates an installation of VMWare Tools on the VM
vim-cmd hostsvc/maintenance_mode_enterPut the host into maintenance mode.
vim-cmd hostsvc/maintenance_mode_exitTake the host out of maintenance mode.
vim-cmd hostsvc/net/infoShow networking information of the host.
chkconfig -lShow services running on the host. Can also be used to change startup configuration.
esxtopDisplay list of processes and its usage of resources. Works similar to linux top.
esxcfg-infoShow host's configuration and information.
esxcfg-nics -lShow current NIC configuration.
esxcfg-vswitch -lShow current vSwitch configuration.
vmkerrcode -lDisplay a reference list of VMKernel return codes and descriptions.
dcuiStart the console UI (when accessing through SSH).
vsishRun the VMWare Interactive Shell (from SSH).
decodeSel /var/log/ipmi_sel.rawRead IPMI system log of physical server.
Replace vmid with the value you retrieved from the getallvms command (first one in the table).
Replace path with the full path and file name of a VMX-file (= configuration file of a VM).
---------

No comments:

Post a Comment