ESXCLI commands that helped me a lot

ESXCLI commands that helped me a lot

https://blog.csdn.net/VirtualMan_/article/details/105455194

This article will share some cool ESXCLI commands. The vSphere client has a great GUI that can help you complete most of the daily tasks, but if you master ESXCLI, your work will be more effective.

Click to read the original text

Insert picture description here

Why is ESXCLI still needed in vSphere

Don't underestimate the command line, it is a useful tool for performing a series of tasks that cannot be done through the vSphere Client. CLI also provides the possibility of automating routine tasks and is also a useful tool for troubleshooting. For more information, please refer to here

https://pubs.vmware.com/vsphere-6-5/index.jsp?topic=%2Fcom.vmware.vcli.ref.doc%2Fvcli-right.html.

The advantage of ESXi is that it is built on the Linux kernel. Therefore, anyone with practical experience in Linux has already mastered some commands (that's why this article starts with Linux commands).

1. Help is one of the most important commands, providing a summary of any other commands.

[some command]–help

Insert picture description here
2. Less is very useful for long output. Use less to display page by page.

Insert picture description here
3. grep allows some filters to be applied to the output to find specific lines more easily.

grep[-HhnlLoqvsriwFEz][-mN][-A/B/CN]PATTERN/-ePATTERN…/-fFILE[FILE]…
Insert picture description here
4. more Display output screen by screen

[some command]| more
more< [path] [file_name]

Insert picture description here
5. esxcli esxclicommand list | more lists all ESXCLI commands and instructions
Insert picture description here
6. dcui starts an SSH session to use the server console.
Insert picture description here
7. cd to change the current directory

сd[][path][~/][-];

8. mkdir creates a directory

mkdir[some directory name][-m][-p]

Insert picture description here
9. ls returns the contents of the directory (that is, lists all files and subdirectories).

ls[-1AaCxdLHRFplinsehrSXvctu][-wWIDTH][FILE]…
Insert picture description here
10. mv moves or renames files or directories

mv [path and filename] [new path] [-f] [-i] [-n]

11. ps displays all active processes
Insert picture description here
Insert picture description here
** 12. cp copies directories or files. **Using this command, you can copy a single file or multiple files at once. By the way, you can rename the file while copying it (sometimes very convenient).

cp [some file 1] [some file 2]
cp [some file 1] … [some directory]
cp -r [somedirectory] … [some directory]

Insert picture description here
13. find 文件搜索

find [-HL][PATH]… [OPTIONS] [ACTIONS]
Insert picture description here
14. cat reads from files and outputs them on the screen.

cat [FILE]…
Insert picture description here

Daily use of CLI example

1. reboot to restart the host

2. poweroff using the command line to shut down

3. esxcli system version get get some information about ESXi version
Insert picture description here
4. esxcli hardware information about host hardware
Insert picture description here
** 5. esxcli hardware pci list get information about all available PCI devices.
**
Insert picture description here
6. esxcli hardware clock (get/set) Get or set the ESXi system time.
Insert picture description here
7. lspci Brief information about available PCI devices.

lspci [-p] [-n] [-d] [-e] [-v] [-h]
Insert picture description here
Insert picture description here
8. esxtop monitors the usage of host resources. The following are the hot keys to switch between views:

C (CPU), I (interrupt), M (memory), N(network), D (disk adapter), U (disk device), V (virtual disk), P (power mgmt).
Insert picture description here
Insert picture description here
**9. vmkerrcode- l Provide more detailed information about the error code. **When there is a problem with the VM, enter this command.
Insert picture description here
10. esxcfg-nics returns more detailed information about the network card

esxcfg-nics [-s] [-d] [-a] [-l] [-e] [-r] [-h]
Insert picture description here
11. esxcfg-vswitch provides information about virtual switches

esxcfg-vswitch [options] [vswitch[:ports]]
Insert picture description here
12. chkconfig -l displays the status of all services in all run levels.

chkconfig[options]
Insert picture description here
13. esxcli software manages and installs configuration files and VIB

esxcli software {cmd}[cmd options]

14. esxcli software vib list lists all installed VIBs.
Insert picture description here
15.esxcli network is used to manage virtual networks

esxcli network{cmd}[cmd options]

16.esxcli network ip connection list lists all active connections
Insert picture description here
17. esxcli storage -a A set of core storage commands and other commands for managing storage.

esxcli storage{cmd}[cmd options]

18.esxcli storage vmfs extent list lists vmfs volumes
Insert picture description here
19. esxcli system storage monitoring and management commands

20. esxcli system version get returns the ESXi version and internal version number.
Insert picture description here
21. uname provides information about the VMware ESXi version.

uname[-amnrspvio]
Insert picture description here

Commands for managing virtual machines

1. vim-cmd vmsvc / getallvms Information about virtual machines running on a specific host
Insert picture description here
2. vim-cmd vmsvc /power.getstate # Use this command to check if the VM is running, enter vmid instead of #
Insert picture description here
3. vim-cmd vmsvc /power.on /off # Turn on or off the specified virtual machine, use vmid instead#

4. vim-cmd vmsvc /power.reset # Reset the virtual machine

5. vim-cmd vmsvc /power.shutdown # Shut down a specific virtual machine

6. vim-cmd vmsvc /power.reboot # Restart the virtual machine

7. vim-cmd vmsvc /get.summary # Provide information about the virtual machine

8. esxcli vm process list lists running virtual machines and their world IDs
Insert picture description here
9. esxcli vm process kill -type=[soft,hard,force] -world-id=WorldID provides many options to stop VMs with a specific WorldID.

Soft-normal shutdown
Hard-immediate shutdown
Force-only use force when restarting the host

10. vim-cmd solo /registervm /vmfs/vol/datastore/dir/vm.vmx Register the VM in the virtual machine management list and assign a Vmid to it.
Insert picture description here
11.vim-cmd vmsvc /unregistervm vmid # Delete the virtual machine from the inventory

to sum up

This article does not list all ESXCLI commands, but only lists some commonly used commands, I hope it will be useful to you.

Related Reading:

NIC load balancing on ESXi hosts: ESXCLI is the first choice

ESXi root password reset

How to install ESXi on vSAN? Just one command line!

100% of the tmp directory in the ESXi system causes the system to become unresponsive.

Insert picture description here

Guess you like

Origin blog.csdn.net/z136370204/article/details/113663187