Pages

VMware CLI All In One

============================================================================================================
                                       VMware ESXi CLI Command List
============================================================================================================
Host Information & System Status
============================================================================================================
esxcli system version get                      --> Show ESXi version and build number
vmware -v                                      --> Show ESXi version (short)
esxcli system hostname get                     --> Display the hostname
esxcli system uptime get                        --> Check host uptime
esxcli hardware cpu list                        --> Show CPU info
esxcli hardware memory get                      --> Show memory info
esxcli hardware platform get                    --> Show hardware platform details
esxcli software profile get                     --> Show installed ESXi software profile
esxcli system maintenanceMode get               --> Check if host is in maintenance mode
esxcli system settings advanced list            --> List advanced system settings
============================================================================================================
Networking
============================================================================================================
esxcli network nic list                         --> List all physical NICs
esxcli network nic get -n vmnicX                --> Details about a specific NIC
esxcli network vswitch standard list            --> List vSwitches
esxcli network vswitch standard portgroup list  --> List port groups
esxcli network ip interface list                --> Show VMkernel interfaces
esxcli network ip route ipv4 list               --> Show IPv4 routes
esxcli network ip route ipv6 list               --> Show IPv6 routes
esxcli network firewall get                      --> Show firewall status
esxcli network firewall set --enabled true/false --> Enable/disable firewall
esxcli network ip dns server list               --> Show DNS servers
esxcli network ip dns search list               --> Show DNS search domains
============================================================================================================
Storage Management
============================================================================================================
esxcli storage core device list                 --> List all storage devices
esxcli storage filesystem list                  --> List datastores
esxcli storage core adapter list                --> Show storage adapters (HBA)
esxcli storage core device stats get -d <device> --> Show storage stats
esxcli storage nmp device list                  --> Show multipathing info
esxcli storage nmp path list                    --> Show all storage paths
esxcli storage nmp device set --device <device> --psp <policy> --> Set path selection policy
esxcli storage core device set --state off/on   --> Disable/Enable a storage device
esxcli storage core path list                   --> Show path status of devices
esxcli storage core claimrule list              --> Show storage claim rules
============================================================================================================
Virtual Machines (VMs)
============================================================================================================
vim-cmd vmsvc/getallvms                         --> List all VMs
vim-cmd vmsvc/power.getstate <VMID>            --> Get VM power state
vim-cmd vmsvc/power.on <VMID>                  --> Power on VM
vim-cmd vmsvc/power.off <VMID>                 --> Power off VM
vim-cmd vmsvc/power.reset <VMID>               --> Reset VM
vim-cmd vmsvc/snapshot.create <VMID> <name> <desc> --> Create snapshot
vim-cmd vmsvc/snapshot.remove <VMID> <snapshotID> --> Remove snapshot
vim-cmd vmsvc/reload <VMID>                    --> Reload VM configuration
vim-cmd vmsvc/unregister <VMID>                --> Unregister VM from host
vim-cmd vmsvc/message <VMID> "<message>"       --> Send message to VM guest OS
============================================================================================================
Services Management
============================================================================================================
esxcli system services list                     --> List all services
esxcli system services start -s <service>      --> Start a service
esxcli system services stop -s <service>       --> Stop a service
esxcli system services restart -s <service>    --> Restart a service
services.sh restart                             --> Restart all management agents (legacy)
chkconfig --list                                --> List service runlevels and status
============================================================================================================
Security & Users
============================================================================================================
esxcli system account list                      --> List ESXi users
esxcli system account add -i <user> -p <pass>  --> Add user
esxcli system account remove -i <user>         --> Remove user
esxcli system permission list                   --> Show permissions
esxcli system permission set --id <user> --role <role> --> Assign role to user
esxcli system account lock -i <user>           --> Lock user account
esxcli system account unlock -i <user>         --> Unlock user account
============================================================================================================
Logs & Monitoring
============================================================================================================
esxcli system syslog config get                 --> Show syslog configuration
esxcli system syslog reload                     --> Reload syslog
tail -f /var/log/hostd.log                      --> Monitor hostd logs in real-time
tail -f /var/log/vmkernel.log                   --> Monitor VMkernel logs
esxcli system coredump network get              --> Show coredump network settings
esxcli system coredump network set --enable true/false --> Enable/disable coredump network
esxcli hardware ipmi sdr list                   --> Show hardware sensor data (IPMI)
esxcli hardware ipmi sel list                   --> Show hardware event log
============================================================================================================
Host Maintenance & Performance
============================================================================================================
esxcli system maintenanceMode get               --> Check maintenance mode status
esxcli system maintenanceMode set --enable true/false --> Enter/Exit maintenance mode
esxcli hardware cpu global get                  --> Show CPU performance info
esxcli hardware memory get                       --> Show memory usage stats
esxtop                                          --> Real-time performance monitoring


============================================================================================================
                                       VMware ESXi System Configuration Files
============================================================================================================
Host Configuration
============================================================================================================
/etc/hosts                         --> Hostname and IP mapping file
/etc/hostname                      --> ESXi hostname configuration
/etc/resolv.conf                    --> DNS servers and search domains
/etc/syslog.conf                     --> Syslog configuration (legacy)
/etc/vmware/esx.conf                --> Main ESXi host configuration file
/etc/vmware/hostd/hostd.xml         --> Host Management daemon (hostd) configuration
/etc/vmware/hostd/authorization.xml --> Hostd permissions and roles
/etc/vmware/vpx/                   --> vCenter agent configuration files (vpxa)
============================================================================================================
Networking Configuration
============================================================================================================
/etc/vmware/esx.conf                --> Includes vSwitches and VMkernel interfaces
/etc/vmware/esx/portgroups          --> Portgroup definitions
/etc/vmware/esx/vmkernel/interfaces --> VMkernel interface configurations
/etc/vmware/esx/networks.xml        --> Network adapters and VLAN configuration
/etc/network/interfaces             --> Legacy ESXi network interface info
============================================================================================================
Storage Configuration
============================================================================================================
/etc/vmware/esx.conf                --> Includes datastore and HBA configuration
/etc/vmware/storage/core.xml         --> Storage core settings
/etc/vmware/vmfs/                   --> VMFS datastore metadata and UUIDs
/etc/vmware/scsi/                   --> SCSI adapter settings
============================================================================================================
Virtual Machines Configuration
============================================================================================================
/vmfs/volumes/<datastore>/<VM_Name>/<VM_Name>.vmx   --> VM configuration file
/vmfs/volumes/<datastore>/<VM_Name>/<VM_Name>.nvram --> VM BIOS/firmware settings
/vmfs/volumes/<datastore>/<VM_Name>/<VM_Name>.vmdk  --> VM virtual disk descriptor
/vmfs/volumes/<datastore>/<VM_Name>/<VM_Name>.vmxf  --> VM team/folder configuration
/vmfs/volumes/<datastore>/<VM_Name>/<VM_Name>.vmss  --> VM suspend state file
============================================================================================================
Services & Management Configuration
============================================================================================================
/etc/vmware/hostd/                    --> Hostd daemon configs
/etc/vmware/hostd/proxy.xml            --> Hostd proxy settings
/etc/vmware/hostd/vim.xml              --> Hostd VM inventory configuration
/etc/vmware/vpxa/vpxa.cfg              --> vCenter agent configuration file
/etc/vmware/vpxa/logging.conf          --> vCenter agent logging configuration
============================================================================================================
Security & Users
============================================================================================================
/etc/passwd                            --> Local ESXi user accounts
/etc/shadow                            --> Password hashes for ESXi users
/etc/pam.d/                             --> PAM authentication configuration
/etc/vmware/hostd/authorization.xml    --> User permissions and roles
============================================================================================================
Logs & Monitoring
============================================================================================================
/var/log/hostd.log                     --> Host management daemon logs
/var/log/vmkernel.log                  --> VMkernel logs
/var/log/vpxa.log                       --> vCenter agent logs
/var/log/vmkwarning.log                 --> Kernel warnings
/var/log/syslog.log                      --> System logs
/var/run/log                            --> Temporary runtime logs
============================================================================================================
Advanced / Backup-Ready
============================================================================================================
/etc/vmware/esx.conf                     --> Single most important config file for backup
/etc/vmware/hostd/                       --> Backup hostd configs for host management restore
/etc/vmware/vpxa/                         --> Backup vCenter agent configs for vCenter connectivity
/etc/network/                             --> Backup network settings
/etc/ssh/                                 --> Backup SSH configuration if enabled


============================================================================================================
                                       vCenter CLI Cheat Sheet
============================================================================================================
Login & Basic Info
============================================================================================================
ssh root@<vcenter_ip> ---> Login to VCSA shell
hostnamectl ---> Show vCenter hostname and system info
uptime ---> Show vCenter uptime
vpxd -v ---> Display vCenter Server version
vami-cli info ---> Show VCSA system information
appliance-version ---> Show appliance version and build
============================================================================================================
vCenter Services
============================================================================================================
service-control --list ---> List all vCenter services
service-control --start <service_name> ---> Start a vCenter service
service-control --stop <service_name> ---> Stop a vCenter service
service-control --restart <service_name> ---> Restart a vCenter service
service-control --status <service_name> ---> Show status of a service
service-control --all status ---> Show status of all services
============================================================================================================
Networking
============================================================================================================
ip addr show ---> List all network interfaces
ip route show ---> Show network routing table
appliance firewall status ---> Show firewall status
appliance firewall enable <service> ---> Enable firewall for service
appliance firewall disable <service> ---> Disable firewall for service
esxcli network ip dns server list ---> Show DNS servers
esxcli network ip dns search list ---> Show DNS search domains
============================================================================================================
Backup & Restore
============================================================================================================
vami-cli backup list ---> List existing vCenter backups
vami-cli backup create --description "<desc>" --mode file --destination <path> ---> Create backup
vami-cli restore --mode file --source <backup_file> ---> Restore from backup
vami-cli system restore point list ---> List restore points
============================================================================================================
Host / Cluster Management via govc
============================================================================================================
govc host.info ---> List all ESXi hosts in vCenter
govc host.uptime -host <hostname> ---> Show host uptime
govc host.maintenance -enter -host <hostname> ---> Put host in maintenance mode
govc host.maintenance -exit -host <hostname> ---> Exit host from maintenance mode
govc cluster.info /<datacenter>/host/<cluster_name> ---> Show cluster info
govc cluster.addhost -cluster /<datacenter>/host/<cluster_name> <host_ip> ---> Add host to cluster
govc cluster.removehost -cluster /<datacenter>/host/<cluster_name> <host_ip> ---> Remove host from cluster
govc cluster.das.info /<datacenter>/host/<cluster_name> ---> Show HA/DRS settings
============================================================================================================
VM Management via govc
============================================================================================================
govc ls /<datacenter>/vm ---> List all VMs
govc vm.info -json <vm_name> ---> Show VM info
govc vm.power -on <vm_name> ---> Power on VM
govc vm.power -off <vm_name> ---> Power off VM
govc vm.power -reset <vm_name> ---> Reset VM
govc vm.markastemplate <vm_name> ---> Mark VM as template
govc snapshot.create <vm_name> <snapshot_name> ---> Create snapshot
govc snapshot.remove <vm_name> <snapshot_name> ---> Remove snapshot
govc snapshot.revert <vm_name> <snapshot_name> ---> Revert VM to snapshot
govc vm.rename <vm_name> <new_name> ---> Rename a VM
govc vm.clone -vm <vm_name> <new_vm_name> ---> Clone a VM
============================================================================================================
VM Management via PowerCLI
============================================================================================================
Connect-VIServer -Server <vcenter_ip> -User <user> -Password <pass> ---> Connect to vCenter
Get-VM ---> List all VMs
Start-VM -VM <vm_name> ---> Power on VM
Stop-VM -VM <vm_name> ---> Power off VM
Restart-VM -VM <vm_name> ---> Reset VM
New-Snapshot -VM <vm_name> -Name <snapshot_name> ---> Create snapshot
Remove-Snapshot -VM <vm_name> -VM <vm_name> -Name <snapshot_name> ---> Remove snapshot
Set-VM -VM <vm_name> -MemoryGB <size> ---> Change VM memory
Set-VM -VM <vm_name> -NumCPU <count> ---> Change VM CPU
Rename-VM -VM <vm_name> -NewName <new_name> ---> Rename VM
Export-VM -VM <vm_name> -Destination <path> ---> Export VM to OVF/OVA
============================================================================================================
Datastore Management
============================================================================================================
govc datastore.info /<datacenter>/datastore/<datastore_name> ---> Show datastore info
govc datastore.ls -json ---> List all datastores
govc datastore.mkdir /<datacenter>/datastore/<datastore_name>/<folder> ---> Create folder in datastore
govc datastore.rm /<datacenter>/datastore/<datastore_name>/<folder> ---> Remove folder from datastore
govc datastore.upload <local_file> /<datacenter>/datastore/<datastore_name>/<file> ---> Upload file to datastore
govc datastore.download /<datacenter>/datastore/<datastore_name>/<file> <local_file> ---> Download file
============================================================================================================
Users & Permissions
============================================================================================================
govc role.ls ---> List all roles
govc permissions.ls ---> List all permissions
govc permissions.set -principal <user> -role <role> -entity /<datacenter>/vm/<vm_name> ---> Assign role to user
govc permissions.remove -principal <user> -entity /<datacenter>/vm/<vm_name> ---> Remove permission
============================================================================================================
Logs & Monitoring
============================================================================================================
journalctl -u vpxd.service ---> Show vCenter logs
tail -f /var/log/vmware/vpxd/vpxd.log ---> Monitor vCenter log in real-time
appliance-monitoring summary ---> Show VCSA appliance health
appliance-monitoring network ---> Show network monitoring info
============================================================================================================
Advanced / Maintenance
============================================================================================================
vpxd_servicecfg_init ---> Re-initialize vCenter services (advanced)
appliance-shell ---> Enter appliance shell mode
vami-cli services list ---> List VCSA appliance services
vami-cli services restart <service> ---> Restart a specific appliance service
appliance-control --shutdown ---> Shutdown VCSA
appliance-control --reboot ---> Reboot VCSA


============================================================================================================
                                       vCenter System Configuration Files
============================================================================================================
Host & Basic System Configuration
============================================================================================================
/etc/hostname ---> VCSA hostname configuration
/etc/hosts ---> Static IP and hostname mappings
/etc/resolv.conf ---> DNS servers and search domains
/etc/locale.conf ---> Locale and language settings
/etc/vmware/identity/sso.cfg ---> Single Sign-On (SSO) configuration
/etc/vmware/vmdir/config ---> VMware Directory Service (vmdir) config
/etc/vmware/applmgmt/appliance.cfg ---> Appliance management settings
/etc/vmware/applmgmt/applmgmt.cfg ---> Appliance management network config
============================================================================================================
Networking Configuration
============================================================================================================
/etc/network/interfaces ---> Network interfaces and IP configuration
/etc/sysconfig/network-scripts/ifcfg-<interface> ---> Legacy interface config (RHEL-based)
/etc/vmware/network/config ---> VCSA appliance network config
/etc/vmware/network/firewall.xml ---> Firewall rules configuration
/etc/vmware/vami/firewall.conf ---> VAMI firewall settings
============================================================================================================
vCenter Services Configuration
============================================================================================================
/etc/vmware/vpxd/vpxd.cfg ---> Main vCenter Server (vpxd) configuration
/etc/vmware/vpxd/license.cfg ---> vCenter license info
/etc/vmware/vpxd/vpxd-profiler.xml ---> Service profiling configuration
/etc/vmware/vpxd/logging.properties ---> Logging configuration for vCenter services
/etc/vmware/applmgmt/appliance-services.conf ---> Appliance service management configuration
============================================================================================================
Database Configuration
============================================================================================================
/etc/vmware/vpostgres/pg_hba.conf ---> PostgreSQL access control configuration
/etc/vmware/vpostgres/postgresql.conf ---> PostgreSQL database settings
/etc/vmware/vpostgres/data/ ---> PostgreSQL database files for vCenter
/etc/vmware/vpostgres/data/pg_ident.conf ---> User mapping for database authentication
============================================================================================================
Users & Permissions
============================================================================================================
/etc/passwd ---> Local users on VCSA appliance
/etc/shadow ---> Password hashes for VCSA users
/etc/sudoers ---> Sudo privileges for VCSA users
/etc/vmware/identity/roles.xml ---> SSO user roles and permissions
/etc/vmware/identity/users.xml ---> SSO user configuration
============================================================================================================
Logging Configuration & Logs
============================================================================================================
/var/log/vmware/vpxd/vpxd.log ---> Main vCenter Server log
/var/log/vmware/vpxd/vpxd-profiler.log ---> vCenter profiling log
/var/log/vmware/applmgmt/applmgmt.log ---> Appliance management log
/var/log/messages ---> System-level logs
/var/log/vmware/vpostgres/postgresql.log ---> vCenter PostgreSQL logs
/var/log/vmware/sso/ ---> SSO service logs
7. Backup & Restore Configuration
/etc/vmware/vami/backup.conf ---> VCSA backup configuration
/etc/vmware/vami/restore.conf ---> VCSA restore configuration
/var/lib/vami/backup/ ---> VCSA backup storage location
============================================================================================================
Advanced / Miscellaneous
============================================================================================================
/etc/vmware/applmgmt/ssl/certs/ ---> SSL certificate files for appliance
/etc/vmware/ssl/ ---> vCenter SSL certificate store
/etc/vmware/applmgmt/ceip.conf ---> VMware Customer Experience Improvement Program (CEIP) settings
/etc/vmware/applmgmt/health.xml ---> Appliance health monitoring configuration
/etc/vmware/applmgmt/network.xml ---> Appliance network monitoring configuration

No comments:

Post a Comment