Top 20 Essential ESXCLI Commands You Need To Know

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

About Altaro Altaro VM Backup

VMware » Automation and Management » Top 20 Essential


ESXCLI Commands You Need to Know

Top 20 Essential ESXCLI


Commands You Need to Know
28 Aug 2017 by Jason Fenech

18

Rate this (6 Votes)

If command lines are your bread and butter, you probably


already know about esxcli commands and how they are
used to perform management and con guration tasks on
ESXi. If on the other hand, this is all new to you, this post
will hopefully give you a head start. For the time being,
you just need to know that esxcli commands are run from
the ESXi shell. If the command line is something you want
to delve into, consider having a look at the PowerCLI

https://www.altaro.com/vmware/top-20-esxcli-commands/ 1/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Primer series. With that out the way, let’s get on with the
About Altaro Altaro VM Backup
show.

ESXi Shell and ESXCLI

If it is not already, the rst thing you need to do is enable


shell on ESXi, something that is generally disabled for
security reasons. To enable Shell, follow the steps
provided in KB 2004746. Once you enable it, you can use
a tool like putty to access Shell via an SSH session.
Alternatively, pressing ALT-F1 while in DCUI is one other
way of accessing Shell. To run commands in shell, log in
as root or with an account having similar privileges.

Accessing ESXi shell using an SSH client or directly from console

The esxcli command exposes a number of namespaces


against which you can run queries to retrieve information
about ESXi as well as con gure it. The following table
lists the available namespaces on ESXi 6.5 along with a
description for each (source: VMware). For earlier ESXi
releases, consult the relevant online documentation or
run esxcli with no parameters to see which namespaces
are available.

Command Description

esxcli device Lists descriptions of device commands.

esxcli elxnet Lists descriptions for commands that manage


Emulex elxnet drivers.

esxcli esxcli Lists descriptions of esxcli commands.

esxcli fcoe FCOE (Fibre Channel over Ethernet)


commands

esxcli Graphics commands


https://www.altaro.com/vmware/top-20-esxcli-commands/ 2/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

graphics
About Altaro Altaro VM Backup
esxcli Hardware namespace. Used primarily for
hardware extracting information about the current
system setup.

esxcli iscsi iSCSI namespace for monitoring and managing


hardware and software iSCSI.

esxcli Network namespace for managing virtual


network networking including virtual switches and
VMkernel network interfaces.

esxcli nvme Commands for managing NVMe devices.

esxcli rdma Commands for monitoring RDMA devices.

esxcli sched Manage the shared system-wide swap space.

esxcli Software namespace. Includes commands for


software managing and installing image pro les and
VIBs.

esxcli Includes core storage commands and other


storage storage management commands.

esxcli System monitoring and management


system command.

esxcli vm Namespace for listing virtual machines and


shutting them down forcefully.

esxcli vsan Namespace for Virtual SAN management


commands. See the vSphere
Storage publication for details.

The Top 20 ESXCLI Commands

The following is a compilation of esxcli commands, sorted


by namespace, I tend to use on a regular basis. It is by no
means exhaustive as there are too many examples to
mention. If you want the whole shebang, have a look at
VMware’s documentation site.

System related commands

#1: esxcli system version get

https://www.altaro.com/vmware/top-20-esxcli-commands/ 3/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Description: Returns the ESXi build and version numbers.


About Altaro Altaro VM Backup

#2: esxcli system hostname get

Description: Returns the hostname, domain and FQDN


for the host.

#3: esxcli system stats installtime get

Description: Returns the date and time of when ESXi was


installed.

#4: esxcli system account list

Description: Lists the local users created on the ESXi


host.

https://www.altaro.com/vmware/top-20-esxcli-commands/ 4/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

 
About Altaro Altaro VM Backup
#5: esxcli system account add -d=”Altaro Guest” -
i=”altaro” -p=”dsfewfewf*3!4404″ -
c=”dsfewfewf*3!4404″

Description: This command allows you to create local


ESXi users. All the parameters used in the example are
mandatory.

#6: esxcli system maintenanceMode set –enable true

Description: Use this command to put ESXi in


maintenance mode or take it out.

#7: esxcli system shutdown reboot -d 10 -r “Patch


Updates”

Description: Use this command to reboot or shutdown


ESXi. The -d parameter is a countdown timer; minimum
10 seconds. ESXi must be in maintenance mode before
you can use the command.

Network related commands

#8: esxcli network rewall get

Description: Returns the status of the ESXi rewall. The


default action is to drop traf c unless allowed through by
a speci c rewall rule. The Enabled eld indicates

https://www.altaro.com/vmware/top-20-esxcli-commands/ 5/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

whether the rewall is enabled. The Loaded  eld shows


About Altaro Altaro VM Backup
whether the rewall module is active or not (see esxcli
rewall load | unload commands).

#9: esxcli network rewall set –enabled true | false

Description: Use this command to disable the ESXi


rewall for troubleshooting purposes. Note that disabling
the rewall on ESXi is highly discouraged.

#10: esxcli network rewall ruleset list | awk ‘$2 ==”true”‘

Description: Generates a list of all enabled rewall rules


on ESXi. The command is piped to awk which will
matches the value from the second column to “true” so
only enabled rules are displayed.

#11: esxcli network ip interface ipv4 get

https://www.altaro.com/vmware/top-20-esxcli-commands/ 6/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Description: Displays the IPv4 con guration for all the


About Altaro Altaro VM Backup
interfaces present on ESXi.

Software related commands

#12: esxcli software vib list

Description: Lists all the currently installed VIBs on ESXi.


A VIB is a le packaging format used to distribute
software on ESXi.

#13: esxcli software vib update -d “/tmp/update.zip”

Description: Use this command to update an installed VIB


on ESXi. Note that the command does not install any new
software. Instead it only updates what’s currently
installed. Use esxcli software vib install instead when
installing new software. The -d parameter speci es the
full path to the package being used for the update. As
per the next screenshot, I speci ed a non-existing patch
hence the error message.

Virtual Machine related commands

#14: esxcli vm process list

Description: Lists all the running VMs on the hosts. The


World ID can be used with other commands to carry out
https://www.altaro.com/vmware/top-20-esxcli-commands/ 7/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

various tasks related to VMs.


About Altaro Altaro VM Backup

#15: esxcli vm process kill -w 69237 -t soft

Description: Use this command to kill a running VM such


as one that fails to respond to commands. You must rst
retrieve the VM’s World ID (see command #14) and pass
it on using the -w parameter. The -t <soft | hard | force>
mandatory parameter sets the type of kill operation. Start
with soft so you allow the VM to shut down cleanly. If this
does not work, try the hard option which will kill the VM
processes immediately as in kill -9. The Force type should
only be used as a last resort. If none work, your only
option is to reboot ESXi.

Storage related commands

#16: esxcli storage vmfs extent list

Description: The command generates a list of extents for


each volume as well as the corresponding device name to
UUID mapping.

#17: esxcli storage lesystem list

https://www.altaro.com/vmware/top-20-esxcli-commands/ 8/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Description: The command lists of all the volumes or


About Altaro Altaro VM Backup
datastores accessible by the ESXi host. The output
includes the le system type, disk info along with the
volume name, path and UUID.

iSCSI related commands

#18: esxcli iscsi software set –enabled true && esxcli iscsi


software get

Description: The above command actually consists of two


concatenated commands, which is what && does. The
rst command enables the iSCSI software adapter and
the second veri es that the iSCSI adapter is enabled.

#19: esxcli iscsi adapter param get -A vmhba65

Description: The command returns metrics for the


speci ed iSCSI adapter. These include the current,
minimum and maximum values and whether the listed
parameters may be con gured or not. The name of the
iSCSI adapter you want to be queried is speci ed via the
-A parameter. The adapter name is retrieved using esxcli
iscsi adapter list or from the vSphere Web client.

https://www.altaro.com/vmware/top-20-esxcli-commands/ 9/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

 
About Altaro Altaro VM Backup

Available ESXCLI commands

#20: esxcli esxcli command list

Description: Lists all the available namespaces and


corresponding commands.

Wrap Up

We’ve seen how you can use esxcli to query ESXi as well
as it for con guration tasks. It is a great command to
master, so make sure you familiarize yourself with it.
Hopefully, this post has given you a taste of what it can
do and how command line is sometimes better suited at
accomplishing a given task such as upgrading ESXi from
the command line, something I explain in Patching and
Upgrading ESXi using ESXCLI commands.

     

Download Altaro VM Backup

https://www.altaro.com/vmware/top-20-esxcli-commands/ 10/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Start your free 30-day trial of Altaro VM


About Altaro Altaro VM Backup
Backup today and see why it's trusted by 40
000+ organizations worldwide. Get started
now and run your rst backup in under 15
mins!

Download Now

Get noti ed about new VMware


articles, eBooks and webinars!

Name

Email

Yes, sign me up for more VMware


awesomeness!

I'm not a robot


reCAPTCHA
Privacy - Terms

Jason Fenech
An IT veteran for over 23 years, I
covered various roles throughout
my career. Prior to joining Altaro as
a blog writer and QA tester, I was
employed as an infrastructure
engineer at a cloud services
provider working exclusively with
VMware products. The Altaro
VMware blog enables me to share
the experience and knowledge
gained and, much to my surprise, is
what got me the vExpert 2017
award. Besides being a techie and
a science buff, I like to travel and

https://www.altaro.com/vmware/top-20-esxcli-commands/ 11/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

play guitars. I also do some


About Altaro Altaro VM Backup
photography and love having a go
at playing the occasional XBOX
game, Halo being my absolute
favourite. I am also a proud father
of two and parent to a crazy
Dachshund called Larry.

18 thoughts on "Top 20 Essential


ESXCLI Commands You Need to Know"

David Hesse
on September 1, 2017 at 6:19 pm

Hi Jason, you need to tell people the version of


ESXi-Hosts from which you are running those
esxcli commands.
Many of those namespaces won’t exist on EXi
5.5 U3 Hosts for example.
The list of available name spaces is much
shorter on my servers

In any case, regardless of the ESXi-Host-Version,


typing “esxcli” and hitting enter will show you
the avaiable namespaces.

00
Rate this

Reply

Jason Fenech
on September 4, 2017 at 10:21
am
https://www.altaro.com/vmware/top-20-esxcli-commands/ 12/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Hey David,
About Altaro Altaro VM Backup

Yes, good idea. The commands apply to


ESXi 6.5 so a few namespaces will not be
available on older releases. Will update.

Thanks for the tip.

regards

Jason
00
Rate this

Reply

Paul
on September 27, 2017 at 3:26 am

Very useful article. Thank you for sharing this


information.
00
Rate this

Reply

evilmarci
on April 27, 2018 at 2:05 pm

Hi Jason,

https://www.altaro.com/vmware/top-20-esxcli-commands/ 13/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

thanks for the useful article. Im wonder at


About Altaro Altaro VM Backup
command #10:

esxcli network rewall ruleset list | awk ‘$2


==”true”‘

Why you dont use grep true instaed ?

esxcli network rewall ruleset list | grep true

But anyway interesting usecase for awk

Thx from ger


10
Rate this

Reply

Jason Fenech
on June 5, 2018 at 5:00 pm

Hi. One could use grep but awk looks


cooler
10
Rate this

Reply

Travis
on May 1, 2018 at 8:55 pm

It would be nice if vmware included the simple


top command. Nothing equivalent exists
https://www.altaro.com/vmware/top-20-esxcli-commands/ 14/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

apparently.
About Altaro Altaro VM Backup
00
Rate this

Reply

Travis
on May 1, 2018 at 8:58 pm

I meant to say that it still includes


esxtop however it is now very messed
up, and nothing like the original tree
view like we’re used to.
00
Rate this

Reply

Leandro Berisso
on September 15, 2018 at 4:08 pm

Thanks a lot, Jason. Very useful!


00
Rate this

Reply

https://www.altaro.com/vmware/top-20-esxcli-commands/ 15/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

Justin Joseph
About Altaro Altaro VM Backup
on November 30, 2018 at 10:27 pm

Hi Jason,

The blog is really great for people like me who


have just entered into the world esxcli
command lines and thanks a lot for that.
I’ve been roaming around few issues with my
VMs and I’ve to discover the actual .VMDKs that
are being used by the VM (as I can see several
.vmdk les inside the datastore, many of them
might be obsolete ones and can be deleted)
Could you tell me the esxcli command to get
the details of vmdks that are being used by
certain VM. I couldn’t the right one anywhere
else until now.
00
Rate this

Reply

Ryan Birk
on January 22, 2019 at 9:55 pm

I think you might be looking for the


vmkfstools command. It’s not esxcli, but
will give you various details that you
might be looking for.
00
Rate this

Reply

https://www.altaro.com/vmware/top-20-esxcli-commands/ 16/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

JUSTIN JOSEPH
About Altaro Altaro VM Backup
on January 25, 2019 at
8:12 pm

Thanks, I got it.


00
Rate this

Reply

David Hesse
on January 22, 2019 at 10:45 pm

you could run a quick PowerCLI one


liner to see that VMDK les your VM is
actually using.

open up a PowerShell session, connect


to your vCenter-Sercer and run the
following command:
Get-VM | Get-Harddisk | Select Name,
Disktype, StorageFormat, Persistence,
CapacityGB, Filename | FT -Autosize
00
Rate this

Reply

Justin Joseph

J 25 2019 t 8 12
https://www.altaro.com/vmware/top-20-esxcli-commands/ 17/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know
on January 25, 2019 at 8:12 pm
About Altaro Altaro VM Backup

Great, it works. Thanks a lot.


00
Rate this

Reply

Featured product

Download 30-
day trial

More info

Altaro O365
Backup Free Trial

Download 30-
day trial

More info
https://www.altaro.com/vmware/top-20-esxcli-commands/ 18/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

About Altaro Altaro VM Backup

Latest Altaro
VMware eBook

Download
eBook

View all
eBooks

Categories

VSPHERE

STORAGE

AUTOMATION

AND MANAGEMENT

ALTARO NEWS

DESKTOP

VIRTUALIZATION

HYPERCONVERGENC

https://www.altaro.com/vmware/top-20-esxcli-commands/ 19/20
9/4/2019 Top 20 Essential ESXCLI Commands You Need to Know

About Altaro Altaro VM Backup


CLOUD

Altaro VM Backup About Altaro Try Altaro VM


Backup
Overview About AltaroCareers

Hyper-V Backup Contact News Free 30-day trial of


Altaro VM Backup
VMware Backup Partners Resources

Mixed Environments Hyper-V MSP Dojo


Dojo Start Here
Altaro VM Backup for
MSPs

Find us on

© 2019 Altaro All rights reserved.

https://www.altaro.com/vmware/top-20-esxcli-commands/ 20/20

You might also like