When working with VMware ESXi and vSphere, there is a time when you have to go into the CLI and fix problems, look for details which you don't get through the UI or those details would be many clicks away. During those times you might appreciate to know and learn our selection of Top 5 Useful VMware ESXi CLI Commands.
There are many commands to know, but let's keep it simple for starters. Let's start to learn some really the useful ones. For example, you need to shut down a VM which you can't shut down or access through vSphere Web client or ESXi host client. This VM is unresponsive.
Or, you might be looking the exact build number of the ESXi host and since when it was installed.
Experienced VMware admins, I'm sure, know those already. But new people starting to learn VMware technology will certainly appreciate this guiding post.
Top 5 Useful VMware ESXi CLI Commands
“Softly” stop VM which is unresponsive.
Well, we will start with this one. In case the VM is frozen within the console and cannot be shut down gracefully through the console, you might want to try to shut down a VM gracefully via the CLI. You'll need a SSH access to connect remotely to your ESXi host and use an SSH client such as Putty.
We can stop (Kill) a VM which is unresponsive, and we have already done a post on that here – How to Power Off an Unresponsive VM. But today we'll do that more gently first. We'll use the soft switch to do that.
First, enter this command:
esxcli vm process list
to see the world ID number.
The do enter this
esxcli vm process kill -w 69135 -t soft
You have other options. “Hard” and “Force”. The -t switch can actually have 3 different options. (soft | hard | force). It is a mandatory parameter which sets the type of kill operation.
- Soft – clean shutdown.
- Hard – It will kill the VM processes immediately as in kill -9.
- Force – The Force type should only be used as a last option (before rebooting the host).
Check which VIBs are installed on your ESXi host
VIBs are all the VMware drivers loaded. You can read my detailed post about How to install VIB on VMware ESXi here. Or check our post explaining Acceptance Levels and VIBs here.
You'll want to use this command to list all VIBs.
esxcli software vib list
The output looks like this:
Install time of your ESX host?
That's an interesting one. Even if not the most important one. I agree. But it's cool to be able to find out quickly the install date of your ESXi. Right?
Use this command:
esxcli system stats installtime get
7th of July 2017 -:). Nice.
ESXi Firewall Status Check
Another command which is useful is perhaps a command checking the firewall. If it's active or not.
Use this command:
esxcli network firewall get
It will just show you an output.
Here we can go further and show you how to enable or disable firewall, while we are here. It's pretty simple.
Use this:
esxcli network firewall set -e false
or
esxcli network firewall set -e true
if you want to disable or not your ESXi firewall.
Quickly show which version of ESXi you're running
Use this command to show ESXi version
esxcli system version get
The output looks like this:
You could get similar info through vSphere client, but not all.
Last one command which might be useful for exploring other commands that we haven't listed here. This command will list all commands.
esxcli esxcli command list
But you might want to use grep in order to filter because the list is just way too long.
For example
esxcli esxcli command list | grep time
gives all possible commands which have the word “time” in it. It's a good way to find commands related on what you're looking for.
The esxcli system is very rich command giving you access to the whole “system” namespace. But similar way you can also select other namespaces by typing simply
esxcli
This gives you the option to select the namespace you want.
More posts from ESX Virtualization:
- VMware vSphere 8.0 U2 Released – ESXi 8.0 U2 and VCSA 8.0 U2 How to update (NEW)
- What’s the purpose of those 17 virtual hard disks within VMware vCenter Server Appliance (VCSA) 8.0?
- VMware vSphere 8 Update 2 New Upgrade Process for vCenter Server details
- VMware vSAN 8 Update 2 with many enhancements announced during VMware Explore
- What’s New in VMware Virtual Hardware v21 and vSphere 8 Update 2?
- Homelab v 8.0
- vSphere 8.0 Page
- Veeam Bare Metal Recovery Without using USB Stick (TIP)
- ESXi 7.x to 8.x upgrade scenarios
- A really FREE VPN that doesn’t suck
- Patch your ESXi 7.x again
- VMware vCenter Server 7.03 U3g – Download and patch
- Upgrade VMware ESXi to 7.0 U3 via command line
- VMware vCenter Server 7.0 U3e released – another maintenance release fixing vSphere with Tanzu
- What is The Difference between VMware vSphere, ESXi and vCenter
- How to Configure VMware High Availability (HA) Cluster
Stay tuned through RSS, and social media channels (Twitter, FB, YouTube)
Jody Whitlock says
Very nice article. I often use ESXCLI from PowerCLI, so I can easily tab-complete most of the namespaces but sometimes I do need to ssh in and it’s usually a little fumbling around.