Appendix B Common Linux and ESX Commands

Navigating the Service Console command line and performing management, configuration, and troubleshooting tasks is an important skill set for virtual infrastructure administrators.

This appendix discusses the following topics: navigating and managing the Service Console, managing disks and files in the Service Console, and using esxcfg, a management tool from VMware.

Navigating, Managing, and Monitoring through the Service Console

First and foremost, getting around the service console is a critical skill for troubleshooting and managing ESX Server hosts when the traditional graphical tools are not available. The following commands are some of the common and basic commands for moving around a Linux-based operating system.

cd Used to change directories.

Example: #cd /vmfs/volumes

ls Used to list files and folders in the current directory.

Example: #ls

ls -l Used to list files and folders in a long format with rights and owners.

ls -s Used to list files and folders in a short format.

ls -R Used to list files and folders with the ability to scroll.

whoami Used to identify the effective user.

who am i Used to identify the currently logged-on user.

logout Used to log out the current user.

reboot Used to reboot a system.

adduser Used to add a new user.

Example: useradd newaccount

passwd Used to update a user account password.

Example: passwd newaccount

Managing Directories, Files, and Disks in the Service Console

Without a graphical interface to use creating, managing, and deleting files and directories will have to be done in the console session. The following commands provide basic instruction on moving, copying, creating, and deleting files and directories.

mv Used to move or rename files.

Example 1: mv oldfile newfile

Example 2: mv file1/newfolder/file1

cp Used to copy directories or files. Can be used to rename a file during the copy process.

-f to force the copy

-p to copy the permissions

Example 1: cp file1/newdocs/file1

Example 2: cp file1/newdocs/file2

rm Used to remove files and directories.

-f to force the removal

Example: rm -f /olddirectory

rmdir Used to remove empty directories.

Example: rmdir

touch Used to create a new file or change file access and modification time.

Example: touch mynewfile.txt

fdisk Used to manage disk partitions.

mount Used to mount CD-ROM or floppy drives.

Example: mount /mnt/cdrom

Using esxcfg

In addition to the standard Linux commands covered thus far VMware has implemented a specific set of commands directed toward ESX-specific tasks. The following list of commands show how to manage various components of the ESX Server configuration.

esxcfg-auth Used to configure an ESX Server host to support network-based authentication methods (e.g., Active Directory [AD]).

--enablead to configure Service Console for AD authentication

--addomain to set the domain the Service Console will authenticate against

--addc to set the domain controller to authenticate against for AD authentication

--usecrack to enable the pam_cracklib for managing password complexity

esxcfg-firewall Used to query, enable, and disable services on the Service Console firewall.

-q to query the current firewall settings

-q servicename to query the status of a specific service

-q incoming/outgoing to query the status of incoming and outgoing ports

--blockIncoming to block all incoming connections on ports not required for system function

--blockOutgoing to block all outgoing connections on ports not required for system function

--allowIncoming to allow incoming connections on all ports

--allowOutgoing to allow outgoing connections on all ports

--e servicename to enable a specific service

--d servicename to disable a specific service

esxcfg-info Used to review the hardware information for Service Console and VMKernel.

-w to print hardware information

-s to print storage and disk information

-n to print network information

esxcfg-mpath Used to view and configure the multipathing settings for an ESX Server host's fibre channel or iSCSI storage devices.

-p to set the policy for mru (most recently used), fixed, or rr (round-robin)

-P to define a path to operate on

-s with "on" or "off" to enable or disable a specific path

-f to set a specified path as the preferred

esxcfg-nas Used to configure NAS storage on ESX Server.

-l to list all NAS

-a to add a new NAS datastore on a specified host

-o to provide the name of the NAS host

-s to provide the name of the NAS share

-delete to delete a NAS datastore

esxcfg-nics Used to obtain information about and configure the physical network adapters installed in an ESX Server host.

-s to set the speed of a card to 10, 100, 1000, or 10,000.

-d to set the duplex to half or full

esxcfg-route Used to configure the default gateway for the VMkernel.

esxcfg-swiscsi Used to configure the software iSCSI component of ESX Server.

-e to enable software iSCSI

-d to disable software iSCSI

-q to query if software iSCSI is enabled

-s to scan for new LUNs using software iSCSI

esxcfg-vmhbadevs Used to obtain information about the LUNs available to the ESX Server.

-m to print the VMFS UUID if formatted as VMFS

esxcfg-vmknic Used to configure the VMkernel NIC.

-a to add a VMkernel port group

-d to delete a VMKernel

-e to enable the VMkernel NIC

-D to disable the VMkernel port

-i to set the IP address of the VMkernel NIC

-n to set the network mask for the IP of the call

esxcfg-vswif Used to set the parameters of the Service Console

-a to add a Service Console NIC (this option is predicated on having IP information and port group names)

-d to delete a the Service Console NIC

-e to enable the Service Console NIC

-D to disable the Service Console NIC

-p to set the port group name for the Service Console NIC

-i to set the IP address to be used for the Service Console NIC

-n to set the network mask of for the Service Console NIC

esxcfg-vswitch Used to add, remove, or modify a virtual switch.

-a to add a new virtual switch

-d to delete a new virtual switch

-l to list all existing virtual switches

-L to unlink a network adapter from a hosting provider

-U to link a network adapter

-v to set the vLAN ID for a port group

-A to add a new port group

-D to delete a port group

-C to query for the existence of a port group name

Using vicfg

The latest updates to the VI3 product suite, ESX Server 3.5, ESXi, and VirtualCenter 2.5 have also brought about the introduction of a new set of command line tools in the vicfg. The commands are similar to the esxcfg commands but are more directly dedicated to remote host management functions using the new remote command line interface tool available from VMware.

vicfgvicfg-nas Used to manipulate NAS/NFS.

--add or -a to add a new NAS file system

--delete or -d to delete a NAS file system

--help to display help text

--nasserver or -o followed by to add the hostname of the new NAS file system

--share or -s used with -a to provide the name of the directory that is exported on the NAS device

--vihost or -h followed by to direct the command to a particular ESX Server host

vicfg-vmhbadevs Used to discover information about available LUNs.

--help to display help text

--query or -q to print the output in 2.6 compatibility mode

--vihost or -h followed by to direct the command to a particular ESX Server host

--vmfs or -m to print the VMFS UUID in addition to the HBA and /dev names for LUNs that are formatted as VMFS

vicfg-mpath Used to manipulate multipathing.

--help to display help text

--bulk or -b to show all LUNs and paths in parseable format

--detailed or -d to show all information about a LUN, including its globally unique name

--hbas or -a to print the list of HBAs that can be identified by a unique ID

--list or -l to list all LUNs on the system and the paths to each LUN

--lun or -L followed by to specify the LUN to use in the operations command (this option is not used by itself)

--path or -P followed by to specify the path to use in the operations command (this option is not used by itself)

--policy or -p followed by [mru | fixed] to set the policy for a given LUN (the option for round-robin (rr) can be used but is still experimental)

--preferred or -f to set the specified path (--path) as the preferred path

--query or -q to query a LUN for information

--state or -s followed by on or off to enable or disable a given path

--vihost or -h followed by to direct the command to a particular ESX Server host

vicfg-rescan Used to perform a rescan for discovering new LUNs.

--help to display help text

--vihost or -h followed by to direct the command to a particular ESX Server host to provide the name of the adapter to rescan (i.e., vmhba1)

vicfg-dumppart Used to query, set, and scan diagnostic partitions on ESXi.

--activate or -a to activate the configured diagnostic partition (performs the same as --set)

--deactivate or -d to deactivate the currently active diagnostic partition

--find or -f to find all diagnostic partitions

--get-active or -t to get the active diagnostic partition for the system

--get-config or -c to get the configured diagnostic partition for the system

--list or -l to list all partitions on the system that can act as a diagnostic partition

--set or -s followed by to set the active and configured diagnostic partition

--vihost or -h followed by to direct the command to a particular ESX Server host

vicfg-nics Used to report on and manage physical network adapters.

--help to display help text

--auto or -a to set the given adapter to autonegotiate the speed and duplex settings

--duplex or -d followed by [full | half ] to set the duplex value for a given NIC

--speed or -s followed by to set the speed value for a given NIC

--list or -l to list the physical adapters in the system

--vihost or -h followed by to direct the command to a particular ESX Server host

vicfg-vmknic Used to configure virtual network adapters.

--help to display help text

--add or -a to add a virtual network adapter to the system (an IP address and port group name must be specified)

--del or -d followed by to delete the virtual network adapter on the specified port group

--ip or -i followed by [| DHCP] to set the virtual network adapter to a given IP address or to obtain an address from a DHCP server

--list or -l to list virtual network adapters on the system

--netmask or -n followed by to set the network mask for the assigned IP address

--vihost or -h followed by to direct the command to a particular ESX Server host

vicfg-vswitch Used to configure virtual switches.

--help to display help text

--add or -a followed by to add a new virtual switch

--add-pg or -A followed by to add a port group to the specified switch

--check or -c followed by to check for the existence of a virtual switch

--check-pg or -C followed by to check for the existence of a port group

--delete or -d followed by to delete the specified virtual switch (this command will not work if any of the virtual switch ports are in use)

--del-pg or -D followed by to delete the specified port group (this command will not work if the port group is in use)

--link or -L followed by to add a physical adapter to a virtual switch

--list or -l to list all virtual switches and port groups

--mtu or -m to set the maximum transmission unit (MTU) of the virtual switch

--pg or -p followed by to provide the name of a port group when using the

--vlan option (use the ALL parameter to set VLAN IDs on all port groups of a virtual switch)

--vlan or -v to set the VLAN ID for a specific port group (using the parameter 0 disables all VLAN IDs; using --vlan requires the --pg option)

--vihost or -h followed by to direct the command to a particular ESX Server host

vicfg-route Used to configure the default route for VMkernel ports.

--help to display help text

--vihost or -h followed by to direct the command to a particular ESX Server host to specify the default gateway to be used by the VMkernel

vicfg-ntp Used to configure NTP settings.

--help to display help text

--add or -a followed by to add an NTP server

--delete or -d followed by to delete an NTP server

--list or -l to list the configured NTP servers

--vihost or -h followed by to direct the command to a particular ESX Server host

Загрузка...