vSphere ESXi CLI Cheat Sheet: Essential Commands for Configuring and Troubleshooting VMs
Scenario:
It is not uncommon for network administrators to use VMware commands either for personal preference or because the graphical interface is not working properly. As the junior network security administrator of Just Ducky, Inc. you have been assigned to research 15 of the most common vSphere ESXi CLI commands and create a cheat sheet that will help your coworkers in case they need to configure/troubleshoot VMs.
Examples include:
the command to turn on and off VMs
changing time zones
managing files
update drivers
apply patches
taking a snapshot
create backups
network troubleshooting
and more
vSphere ESXi CLI Cheat Sheet: Essential Commands for Configuring and Troubleshooting VMs
As a junior network security administrator, it is crucial to have a comprehensive understanding of the most common vSphere ESXi CLI commands to efficiently configure and troubleshoot virtual machines (VMs). This cheat sheet provides a handy reference for 15 essential commands that will assist you and your coworkers in managing VMs effectively.
1. Power Management
To power on a VM: vim-cmd vmsvc/power.on [vmid]
To power off a VM: vim-cmd vmsvc/power.off [vmid]
2. Time Zone Configuration
To list available time zones: esxcli system settings advanced list -o /UserVars/HostDateTimeZone
To change the time zone: esxcli system settings advanced set -o /UserVars/HostDateTimeZone -i [timezone]
3. File Management
To list files in a directory: ls [directory_path]
To create a new directory: mkdir [directory_name]
To remove a file or directory: rm [file/directory_path]
4. Driver Management
To list installed drivers: esxcli software vib list
To install a driver from a VIB file: esxcli software vib install -v [vib_file_path]
To remove a driver by VIB name: esxcli software vib remove -n [vib_name]
5. Patch Management
To list all available patches: esxcli software sources profile list -d [patch_url]
To install a specific patch: esxcli software profile update -p [profile_name] -d [_url]
6. Snapshot Management
To take a snapshot of a VM: vim-cmd vmsvc/snapshot.create [vmid] [snapshot_name] [snapshot_description]
To revert to a specific snapshot: vim-cmd vmsvc/snapshot.revert [vmid] [snapshot_id]
To remove a snapshot: vim-cmd vmsvc/snapshot.removeall [vmid]
7. Backup and Restore
To create a backup of a VM: vmkfstools -i [source_disk_path] [destination_disk_path]
To restore a VM from a backup: vmkfstools -i [backup_disk_path] [restored_disk_path]
8. Network Troubleshooting
To check network: esxcfg-vmknic -l
To display network statistics for a specific VM: esxtop -> Press 'n' -> Find VM -> Press 'Enter'
9. Resource Management
To monitor CPU usage of a specific VM: esxtop -> Press 'c' -> Find VM -> Press 'Enter'
To monitor memory usage of a specific VM: esxtop -> Press 'm' -> Find VM -> Press 'Enter'
Please note that some commands may require administrative privileges or additional options depending on your specific environment or requirements. Always consult the official VMware documentation for detailed information on each command and its usage.
With this cheat sheet, you and your coworkers will have quick access to the most commonly used vSphere ESXi CLI commands, allowing you to efficiently configure and troubleshoot VMs within your network infrastructure. Remember to exercise caution when using these commands and ensure that you have the necessary permissions before making any changes.