esxcfg-vswitch –l Display the information of Switch
esxcfg-vswitch –a vswitch1 Creates a virtual switch
esxcfg-vswitch –A “service console” vswitch1 Creating a service console switch
esxcfg-vswitch –L vmnic1 vswitch1
esxcfg-vswitch –v
esxcfg-vswif –a vswif0 –I
vmware-cmd -l Display the guest OS information
vm-support –x Display the VMID Value
vm-support –X
service mgmt-vmware restart Restart the Management agent of Vmware Esx server
service network restart Restart the network Service
esxcfg-vswif –l List of virtual network Adapters
esxcfg-vswitch –l List of virtual switch
esxcfg-vswif --del vswif0 Deleting the vswif adapter
esxcfg-vswitch -d vSwitch0 Deleting the vSwitch
cat /etc/sysconfig/network
NETWORKING=yes
GATEWAYDEV=vswif0
HOSTNAME=host.domain.com
GATEWAY=nnn.nnn.nnn.nnn verify that the settings in the network file are correct
service /etc/init.d/ vmware-webAccess status
service /etc/init.d/ vmware-webAccess start
service /etc/init.d/ vmware-webAccess restart
service /etc/init.d/ vmware-webAccess stop Web Browser is not working, we need to check this commands
service vmware-vpxa restart Restart the virtual center agent
vmfsktools -i
Simple Service Commands
Get help on a command man reboot or
reboot –help This works with both Linux & ESX commands. Q to quit
Gives you short explanation
View Last 10 commands history
tail History normally list your past commands, used with tail it will filter to show only the last 10
Clear the screen Clear Same as CLS in a cmd prompt
Switch to being root su - It is regarded as good practice to login with a VM Administrator
account and then switch to being ROOT if required. The minus sign switches bash to ROOT and ROOT’s environment. Without you would have the rights of root, but command might fail due to being in the incorrect path for the executable
Currently logged in user whoami or
id I find it especially important to know who I am in all situations.
Failure to know who you are can result in surprising results. Id
shows your group membership as well
Change the Date/Time date –u 0701180504 The –u switch indicates the UTC format is being used. Numbers
equate to mm/dd/hh/mm/yy
Display ESX Version
Number vmware –v Should display information along this kind “VMware ESX Server
2.5.0 build-11343
Get help on a Command vmware –? or vmware –help Prints to console a quick list of switches and their meaning
Get a manual page on
a command man su Open a more detail page of information about a command or utility
Search Man pages by index Makewhatis
man –k partition Makewhatis man –k partition
Reboot ESX Server Reboot Reboots the server, does not ask are you sure… are you really sure?
Shutdown shutdown now “Server shutting down for maintenance” Shuts down the VM’s and stops remote access – physical console is still accessible
Shutdown & Halt shutdown –h now “server shutting down for maintenance” Shuts down the VM’s; Stops Remote Access – and does a fault halt of the system… Swap file is deactivated, and volumes un-mounted
File & Folder Management
Purpose Syntax Example/Sample Notes
List files ls -l In PuTTy this colour codes the files, and directories and shows Type,Permissions, Group, User, Size (b) Date, and filename
List files with a pause ls –l
more The
is the pipe symbol commonly found where the \ is on a UK keyboard
List hidden files ls –a l Shows files that are hidden – files are made hidden if prefixed with a period, such as ./install
Full Path location Pwd Like what would see in a DOS command prompt
Return to the root cd / You have to put a space between d and /
Return one directory
up cd .. Again, you need a space between cd and ..
Go to home directory cd CD on its own returns you to the home directory of the current users
Type the contents of a
file cat instructor1.vmx
less instructor1.vmx Same as the TYPE command in DOS
Works better with longer files – use the keystroke [Q] to quit like
Man
Search for string
inside a file grep lavericm /etc/passwd Here we are searching for a piece of text called lavericm in the file
called passwd
Use a command
together with grep ls /etc -l
grep vmware Here we are listing all the files in /etc that contain the string vmware
Edit the contents of a
file nano –w /etc/fstab -w disables word wrap and stops unwanted carriage returns
Control+X, [ENTER] [ENTER] exits nano and saves a file
Create/Delete a
directory mkdir /vmimages/iso
rmdir /vmimages/iso Without file path, directory made relative to your path
Delete a file rm filename If your deleting lots of files rm –f *.txt will delete all the txt files but will NOT prompt you
Mount a CD at the Service Console mount /dev/cdrom
ls –l /mnt/cdrom Root only!
Mount an ISO at the
Service Console mkdir /mnt/isocd
mount -o loop -t iso9660 -r /vmimges/esx2.1.iso
/mnt/isocd Create directory for the mount point
-o loop means mount the device as a block device
-t iso9660 means its using the iso file system (as opposed to say Joliet) –r means to mount read-only
Copy a file cp /vmimges/w2k3.iso /vmfs/local Becareful with the use of wildcards if you try to copy every file with *.* as you would with DOS/Windows – this would misout files that DID NOT have extension. So w2k3.iso would be copied but w2k3 would not…
Securely copy a file
from one ESX server
to another scp /vmimages/w2kadvsrv-sp4.iso
root@esxinstructor2.education.vmw:/vmimages/ This uses secure copy. You will prompted with some security
warnings on the first copy for the first time. You will have manually
type the password of the remote machine
Renaming a file/folder mv w2k3.iso cdw2k3.iso Move because effectively, any rename is move procedure. As can be seen in the MUI
Find a file whereis vmsnap.pl If you know the name of a file but can’t remember where it is stored
the whereis command is dead easy to use
Find a file find / -iname '*.conf' Find is much more powerful but can take longer based on your
search criteria. Search here begins at the root / and is caseinsensitive
search by using –iname and ‘*.conf’ would find every
conf file – note ‘ ’ are required – these are ‘single quotes’ not
“double-quotes”
Find a file which
contains a piece of
text find /usr/lib/vmware-mui -iname '*.html' -exec grep -il
'Download VMware Remote Console' {} \; This invokes the find command with the exec switch which allows
you to execute a program based on the find results. Here we are
search every html file which exists in the MUI web directories.
Executing a grep on each file searching for the words ‘Download
VMware Remote Console”. The -i stops case-sensitivity, and –l
causes the file name to printed to the service console session. The
{} is a variable holder for the search string in single quotes. The \
and ; are “end of expression” and “end of command” marker
Find new files find / -mount -mtime -1 -print / is the search point, -mount volumes mounted, -mtime is the
duration and –print is the format for output to the screen
Find files of N size find / -mount –size +10240k This would find files off / taking up more than 10MG
Compress a single file gzip instructor1.dsk –best Works best with single files such a DSK file Caution, automatically deletes original and adds a gz extension to
the file name
hostname newhostname
vi /etc/hosts
vi /etc/sysconfig/network
service network restart
nage Services
service mgmt-vmware restart
Restart Network:
service network restart
Web Access
service vmware-webAccess restart
VMkernel authorization daemon
/etc/init.d/vmware-vmkauthd stop
/etc/init.d/vmware-vmkauthd start
VMware late init tools
service vmware-late restart
Virtualcenter agent
service vmware-vpxa restart
service restart
vmware-cmd –l
Sample:
[root@esxhost root]# vmware-cmd -l
/vmfs/volumes/44ee9812-da790870-b7f7-00145e1b5242/cumuli/cumuli.vmx
/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
List path and names of .registered VM vmx files on the present host
Very important!
Use the path with the UUID (vmfslabel) where requested in vmware-cmd
use vmware-cmd -l command to retrieve the UUID list
vmware-cmd /vmfs/volume/vmfslabel/VMName/VMName.vmx getstate
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx getstate
getstate() = on
Retrieve power state of the VM: off, on, suspended, stuck
getstat
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx reset trysoft
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx reset trysoft
reset(trysoft) = 1 ls VM-Disk and VMFS Management in the console
vmkfstools -X
Extend virtual Disk
vmkfstools -X 12G ./testing.vmdk
To extend an existing Virtual Disk to 12GB. Instead of G you can use M for Megabytes
With the same command you can shrink the disk (only for ESX Version prior to 3.0) if you choose a smaller than the present size. Be aware if the shrinked size is smaller as the partition size in the guest there might be a data losse or a corrupted system resulting!
In some cases the shrink command must be issued with the --force option:
vmkfstools -X 4G ./testing.vmdk --force
For shrinking on ESX 3.0x use the VMWare Converter (download from the VMware Website for freee). Point the source and destination to the same ESX Host.
If you receive an error one parameter was incorrect the size might be smaller as the original size!
If you have blanks in the file or directory name, mask the full path with '
vmkfstools -i
To export or clone a virtual disk from VMFS
vmfsktools -i
Example:
Copy from one vmfs to another:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmfs/volumes/production/testvmnew2.vmdk
vmkfstools -i /vmfs/volumes/esxpublic/testvm2.vmdk /vmfs/volumes/production/testvmnew2.vmdk
Export to ext3 partition:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmimages/testvm2.vmdk
vmkfstools -i /vmfs/esxpublic/testvm2.vmdk -d 2gbsparse /vmimages/testvm2.vmdk
vmkfstools -E
Rename files associated with a specified virtual disk
vmkfstools -U
Delete Virtualdisk
Delete files associated with the specified virtual disk.
vmkfstools -c 4000M ./file.vmdk
To create a new empty virtual disk
vmkfstools -c 300G -a lsilogic /vmfs/volume/vmfslabel/directory/newdisk.vmdk
or in current directory
vmkfstools -c 300G -a lsilogic ./newdisk.vmdk
This command is very useful because you can use user-friendly names for the disks
For further options enter man vmkfstools
Reboot the VM. First try a nice shutdown, then if necessary force a shutdown before reboot
reboot
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx start
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx start
start() = 1
Power on the VM
start
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx stop trysoft
stop(trysoft) = 1
Shutdown/halt the VM. First try a nice shutdown, then if necessary force a shutdown. Finally power off.
shutdown
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx suspend
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx suspend
suspend() = 1
Suspend the VM
suspend vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx hassnapshot
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() =
Query if VM has a snapshot
snapshot vmware-cmd createsnapshot name description quiesce memory
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx createsnapshot "snap1" "before patching" quiesce memory
createsnapshot(snap1 before patching quiesce memory) = 1
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() = 1
Quiesce will quiesce file system writes
Memory will grab the memory state (will lose pings during this)
createsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx revertsnapshot
Sample:
[root@vs03 root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx revertsnapshot
revertsnapshot() = 1
Revert to previous created snapshot (you loose the current VM state!)
revertsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx removesnapshots
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx removesnapshots
removesnapshots() = 1
Remove previous created snapshots (you keep the current VM state!)
removesnapshots vmware-cmd -s register vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s register /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
register(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Register VM (add to inventory)
register vmware-cmd -s unregister vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s unregister /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
unregister(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Unregister VM (add to inventory)
unregister vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx answer
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx answer
No questions pending.
In this case there is no pending input request. If there is any pending input request you will be promptet for the answser.
answer pending request for userinput
Cd etc/init.d
Service vmware-webacess start
Cd etc/ssh
Nano sshd_config
Root permission yes
Esc
CtrlX
Save yes
/sbin/service /ssh restart Service Command sshd on same path
/sbin/service /ssh start
/sbin/service /ssh status
Manage Services
Management agent on the host:
service mgmt-vmware restart
Restart Network:
service network restart
Web Access
service vmware-webAccess restart
VMkernel authorization daemon
/etc/init.d/vmware-vmkauthd stop
/etc/init.d/vmware-vmkauthd start
VMware late init tools
service vmware-late restart
Virtualcenter agent
service vmware-vpxa restart
service restart
vmware-cmd –l
Sample:
[root@esxhost root]# vmware-cmd -l
/vmfs/volumes/44ee9812-da790870-b7f7-00145e1b5242/cumuli/cumuli.vmx
/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
List path and names of .registered VM vmx files on the present host
Very important!
Use the path with the UUID (vmfslabel) where requested in vmware-cmd
use vmware-cmd -l command to retrieve the UUID list
vmware-cmd /vmfs/volume/vmfslabel/VMName/VMName.vmx getstate
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx getstate
getstate() = on
Retrieve power state of the VM: off, on, suspended, stuck
getstat
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx reset trysoft
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx reset trysoft
reset(trysoft) = 1
vmkfstools VM-Disk and VMFS Management in the console
vmkfstools -X
Extend virtual Disk
vmkfstools -X 12G ./testing.vmdk
To extend an existing Virtual Disk to 12GB. Instead of G you can use M for Megabytes
With the same command you can shrink the disk (only for ESX Version prior to 3.0) if you choose a smaller than the present size. Be aware if the shrinked size is smaller as the partition size in the guest there might be a data losse or a corrupted system resulting!
In some cases the shrink command must be issued with the --force option:
vmkfstools -X 4G ./testing.vmdk --force
For shrinking on ESX 3.0x use the VMWare Converter (download from the VMware Website for freee). Point the source and destination to the same ESX Host.
If you receive an error one parameter was incrorrect the size might be smaller as the original size!
If you have blanks in the file or directoryname, mask the full path with '
vmkfstools -i
To export or clone a virtual disk from VMFS
vmfsktools -i
Example:
Copy from one vmfs to another:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmfs/volumes/production/testvmnew2.vmdk
vmkfstools -i /vmfs/volumes/esxpublic/testvm2.vmdk /vmfs/volumes/production/testvmnew2.vmdk
Export to ext3 partition:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmimages/testvm2.vmdk
vmkfstools -i /vmfs/esxpublic/testvm2.vmdk -d 2gbsparse /vmimages/testvm2.vmdk
vmkfstools -E
Rename files associated with a specified virtual disk
vmkfstools -U
Delete Virtualdisk
Delete files associated with the specified virtual disk.
vmkfstools -c 4000M ./file.vmdk
To create a new empty virtual disk
vmkfstools -c 300G -a lsilogic /vmfs/volume/vmfslabel/directory/newdisk.vmdk
or in current directory
vmkfstools -c 300G -a lsilogic ./newdisk.vmdk
This command is very useful because you can use user-friendly names for the disks
For further options enter man vmkfstools
Reboot the VM. First try a nice shutdown, then if necessary force a shutdown before reboot
reboot
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx start
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx start
start() = 1
Power on the VM
start
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx stop trysoft
stop(trysoft) = 1
Shutdown/halt the VM. First try a nice shutdown, then if necessary force a shutdown. Finally power off.
shutdown
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx suspend
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx suspend
suspend() = 1
Suspend the VM
suspend vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx hassnapshot
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() =
Query if VM has a snapshot
snapshot vmware-cmd createsnapshot name description quiesce memory
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx createsnapshot "snap1" "before patching" quiesce memory
createsnapshot(snap1 before patching quiesce memory) = 1
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() = 1
Quiesce will quiesce file system writes
Memory will grab the memory state (will lose pings during this)
createsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx revertsnapshot
Sample:
[root@vs03 root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx revertsnapshot
revertsnapshot() = 1
Revert to previous created snapshot (you loose the current VM state!)
revertsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx removesnapshots
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx removesnapshots
removesnapshots() = 1
Remove previous created snapshots (you keep the current VM state!)
removesnapshots vmware-cmd -s register vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s register /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
register(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Register VM (add to inventory)
register vmware-cmd -s unregister vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s unregister /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
unregister(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Unregister VM (add to inventory)
unregister vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx answer
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx answer
No questions pending.
In this case there is no pending input request. If there is any pending input request you will be promptet for the answser.
answer pending request for userinput
o delete and recreate a virtual switch and Service Console from the command line:
Note: On your system the vswif, vmnic, vSwitch numbers and network settings are different.
esxcfg-nics –l Display the nic card information
esxcfg-vswitch –l Display the information of Switch
esxcfg-vswitch –a vswitch1 Creates a virtual switch
esxcfg-vswitch –A “service console” vswitch1 Creating a service console switch
esxcfg-vswitch –L vmnic1 vswitch1
esxcfg-vswitch –v
esxcfg-vswif –a vswif0 –I
vmware-cmd -l Display the guest OS information
vm-support –x Display the VMID Value
vm-support –X
service mgmt-vmware restart Restart the Management agent of Vmware Esx server
service network restart Restart the network Service
esxcfg-vswif –l List of virtual network Adapters
esxcfg-vswitch –l List of virtual switch
esxcfg-vswif --del vswif0 Deleting the vswif adapter
esxcfg-vswitch -d vSwitch0 Deleting the vSwitch
cat /etc/sysconfig/network
NETWORKING=yes
GATEWAYDEV=vswif0
HOSTNAME=host.domain.com
GATEWAY=nnn.nnn.nnn.nnn verify that the settings in the network file are correct
service /etc/init.d/ vmware-webAccess status
service /etc/init.d/ vmware-webAccess start
service /etc/init.d/ vmware-webAccess restart
service /etc/init.d/ vmware-webAccess stop Web Browser is not working, we need to check this commands
service vmware-vpxa restart Restart the virtual center agent
vmfsktools -i
Simple Service Commands
Get help on a command man reboot or
reboot –help This works with both Linux & ESX commands. Q to quit
Gives you short explanation
View Last 10 commands history
tail History normally list your past commands, used with tail it will filter to show only the last 10
Clear the screen Clear Same as CLS in a cmd prompt
Switch to being root su - It is regarded as good practice to login with a VM Administrator
account and then switch to being ROOT if required. The minus sign switches bash to ROOT and ROOT’s environment. Without you would have the rights of root, but command might fail due to being in the incorrect path for the executable
Currently logged in user whoami or
id I find it especially important to know who I am in all situations.
Failure to know who you are can result in surprising results. Id
shows your group membership as well
Change the Date/Time date –u 0701180504 The –u switch indicates the UTC format is being used. Numbers
equate to mm/dd/hh/mm/yy
Display ESX Version
Number vmware –v Should display information along this kind “VMware ESX Server
2.5.0 build-11343
Get help on a Command vmware –? or vmware –help Prints to console a quick list of switches and their meaning
Get a manual page on
a command man su Open a more detail page of information about a command or utility
Search Man pages by index Makewhatis
man –k partition Makewhatis man –k partition
Reboot ESX Server Reboot Reboots the server, does not ask are you sure… are you really sure?
Shutdown shutdown now “Server shutting down for maintenance” Shuts down the VM’s and stops remote access – physical console is still accessible
Shutdown & Halt shutdown –h now “server shutting down for maintenance” Shuts down the VM’s; Stops Remote Access – and does a fault halt of the system… Swap file is deactivated, and volumes un-mounted
File & Folder Management
Purpose Syntax Example/Sample Notes
List files ls -l In PuTTy this colour codes the files, and directories and shows Type,Permissions, Group, User, Size (b) Date, and filename
List files with a pause ls –l
more The
is the pipe symbol commonly found where the \ is on a UK keyboard
List hidden files ls –a l Shows files that are hidden – files are made hidden if prefixed with a period, such as ./install
Full Path location Pwd Like what would see in a DOS command prompt
Return to the root cd / You have to put a space between d and /
Return one directory
up cd .. Again, you need a space between cd and ..
Go to home directory cd CD on its own returns you to the home directory of the current users
Type the contents of a
file cat instructor1.vmx
less instructor1.vmx Same as the TYPE command in DOS
Works better with longer files – use the keystroke [Q] to quit like
Man
Search for string
inside a file grep lavericm /etc/passwd Here we are searching for a piece of text called lavericm in the file
called passwd
Use a command
together with grep ls /etc -l
grep vmware Here we are listing all the files in /etc that contain the string vmware
Edit the contents of a
file nano –w /etc/fstab -w disables word wrap and stops unwanted carriage returns
Control+X, [ENTER] [ENTER] exits nano and saves a file
Create/Delete a
directory mkdir /vmimages/iso
rmdir /vmimages/iso Without file path, directory made relative to your path
Delete a file rm filename If your deleting lots of files rm –f *.txt will delete all the txt files but will NOT prompt you
Mount a CD at the Service Console mount /dev/cdrom
ls –l /mnt/cdrom Root only!
Mount an ISO at the
Service Console mkdir /mnt/isocd
mount -o loop -t iso9660 -r /vmimges/esx2.1.iso
/mnt/isocd Create directory for the mount point
-o loop means mount the device as a block device
-t iso9660 means its using the iso file system (as opposed to say Joliet) –r means to mount read-only
Copy a file cp /vmimges/w2k3.iso /vmfs/local Becareful with the use of wildcards if you try to copy every file with *.* as you would with DOS/Windows – this would misout files that DID NOT have extension. So w2k3.iso would be copied but w2k3 would not…
Securely copy a file
from one ESX server
to another scp /vmimages/w2kadvsrv-sp4.iso
root@esxinstructor2.education.vmw:/vmimages/ This uses secure copy. You will prompted with some security
warnings on the first copy for the first time. You will have manually
type the password of the remote machine
Renaming a file/folder mv w2k3.iso cdw2k3.iso Move because effectively, any rename is move procedure. As can be seen in the MUI
Find a file whereis vmsnap.pl If you know the name of a file but can’t remember where it is stored
the whereis command is dead easy to use
Find a file find / -iname '*.conf' Find is much more powerful but can take longer based on your
search criteria. Search here begins at the root / and is caseinsensitive
search by using –iname and ‘*.conf’ would find every
conf file – note ‘ ’ are required – these are ‘single quotes’ not
“double-quotes”
Find a file which
contains a piece of
text find /usr/lib/vmware-mui -iname '*.html' -exec grep -il
'Download VMware Remote Console' {} \; This invokes the find command with the exec switch which allows
you to execute a program based on the find results. Here we are
search every html file which exists in the MUI web directories.
Executing a grep on each file searching for the words ‘Download
VMware Remote Console”. The -i stops case-sensitivity, and –l
causes the file name to printed to the service console session. The
{} is a variable holder for the search string in single quotes. The \
and ; are “end of expression” and “end of command” marker
Find new files find / -mount -mtime -1 -print / is the search point, -mount volumes mounted, -mtime is the
duration and –print is the format for output to the screen
Find files of N size find / -mount –size +10240k This would find files off / taking up more than 10MG
Compress a single file gzip instructor1.dsk –best Works best with single files such a DSK file Caution, automatically deletes original and adds a gz extension to
the file name
hostname newhostname
vi /etc/hosts
vi /etc/sysconfig/network
service network restart
nage Services
service mgmt-vmware restart
Restart Network:
service network restart
Web Access
service vmware-webAccess restart
VMkernel authorization daemon
/etc/init.d/vmware-vmkauthd stop
/etc/init.d/vmware-vmkauthd start
VMware late init tools
service vmware-late restart
Virtualcenter agent
service vmware-vpxa restart
service restart
vmware-cmd –l
Sample:
[root@esxhost root]# vmware-cmd -l
/vmfs/volumes/44ee9812-da790870-b7f7-00145e1b5242/cumuli/cumuli.vmx
/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
List path and names of .registered VM vmx files on the present host
Very important!
Use the path with the UUID (vmfslabel) where requested in vmware-cmd
use vmware-cmd -l command to retrieve the UUID list
vmware-cmd /vmfs/volume/vmfslabel/VMName/VMName.vmx getstate
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx getstate
getstate() = on
Retrieve power state of the VM: off, on, suspended, stuck
getstat
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx reset trysoft
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx reset trysoft
reset(trysoft) = 1 ls VM-Disk and VMFS Management in the console
vmkfstools -X
Extend virtual Disk
vmkfstools -X 12G ./testing.vmdk
To extend an existing Virtual Disk to 12GB. Instead of G you can use M for Megabytes
With the same command you can shrink the disk (only for ESX Version prior to 3.0) if you choose a smaller than the present size. Be aware if the shrinked size is smaller as the partition size in the guest there might be a data losse or a corrupted system resulting!
In some cases the shrink command must be issued with the --force option:
vmkfstools -X 4G ./testing.vmdk --force
For shrinking on ESX 3.0x use the VMWare Converter (download from the VMware Website for freee). Point the source and destination to the same ESX Host.
If you receive an error one parameter was incorrect the size might be smaller as the original size!
If you have blanks in the file or directory name, mask the full path with '
vmkfstools -i
To export or clone a virtual disk from VMFS
vmfsktools -i
Example:
Copy from one vmfs to another:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmfs/volumes/production/testvmnew2.vmdk
vmkfstools -i /vmfs/volumes/esxpublic/testvm2.vmdk /vmfs/volumes/production/testvmnew2.vmdk
Export to ext3 partition:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmimages/testvm2.vmdk
vmkfstools -i /vmfs/esxpublic/testvm2.vmdk -d 2gbsparse /vmimages/testvm2.vmdk
vmkfstools -E
Rename files associated with a specified virtual disk
vmkfstools -U
Delete Virtualdisk
Delete files associated with the specified virtual disk.
vmkfstools -c 4000M ./file.vmdk
To create a new empty virtual disk
vmkfstools -c 300G -a lsilogic /vmfs/volume/vmfslabel/directory/newdisk.vmdk
or in current directory
vmkfstools -c 300G -a lsilogic ./newdisk.vmdk
This command is very useful because you can use user-friendly names for the disks
For further options enter man vmkfstools
Reboot the VM. First try a nice shutdown, then if necessary force a shutdown before reboot
reboot
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx start
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx start
start() = 1
Power on the VM
start
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx stop trysoft
stop(trysoft) = 1
Shutdown/halt the VM. First try a nice shutdown, then if necessary force a shutdown. Finally power off.
shutdown
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx suspend
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx suspend
suspend() = 1
Suspend the VM
suspend vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx hassnapshot
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() =
Query if VM has a snapshot
snapshot vmware-cmd createsnapshot name description quiesce memory
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx createsnapshot "snap1" "before patching" quiesce memory
createsnapshot(snap1 before patching quiesce memory) = 1
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() = 1
Quiesce will quiesce file system writes
Memory will grab the memory state (will lose pings during this)
createsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx revertsnapshot
Sample:
[root@vs03 root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx revertsnapshot
revertsnapshot() = 1
Revert to previous created snapshot (you loose the current VM state!)
revertsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx removesnapshots
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx removesnapshots
removesnapshots() = 1
Remove previous created snapshots (you keep the current VM state!)
removesnapshots vmware-cmd -s register vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s register /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
register(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Register VM (add to inventory)
register vmware-cmd -s unregister vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s unregister /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
unregister(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Unregister VM (add to inventory)
unregister vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx answer
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx answer
No questions pending.
In this case there is no pending input request. If there is any pending input request you will be promptet for the answser.
answer pending request for userinput
Cd etc/init.d
Service vmware-webacess start
Cd etc/ssh
Nano sshd_config
Root permission yes
Esc
CtrlX
Save yes
/sbin/service /ssh restart Service Command sshd on same path
/sbin/service /ssh start
/sbin/service /ssh status
Manage Services
Management agent on the host:
service mgmt-vmware restart
Restart Network:
service network restart
Web Access
service vmware-webAccess restart
VMkernel authorization daemon
/etc/init.d/vmware-vmkauthd stop
/etc/init.d/vmware-vmkauthd start
VMware late init tools
service vmware-late restart
Virtualcenter agent
service vmware-vpxa restart
service restart
vmware-cmd –l
Sample:
[root@esxhost root]# vmware-cmd -l
/vmfs/volumes/44ee9812-da790870-b7f7-00145e1b5242/cumuli/cumuli.vmx
/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
List path and names of .registered VM vmx files on the present host
Very important!
Use the path with the UUID (vmfslabel) where requested in vmware-cmd
use vmware-cmd -l command to retrieve the UUID list
vmware-cmd /vmfs/volume/vmfslabel/VMName/VMName.vmx getstate
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx getstate
getstate() = on
Retrieve power state of the VM: off, on, suspended, stuck
getstat
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx reset trysoft
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx reset trysoft
reset(trysoft) = 1
vmkfstools VM-Disk and VMFS Management in the console
vmkfstools -X
Extend virtual Disk
vmkfstools -X 12G ./testing.vmdk
To extend an existing Virtual Disk to 12GB. Instead of G you can use M for Megabytes
With the same command you can shrink the disk (only for ESX Version prior to 3.0) if you choose a smaller than the present size. Be aware if the shrinked size is smaller as the partition size in the guest there might be a data losse or a corrupted system resulting!
In some cases the shrink command must be issued with the --force option:
vmkfstools -X 4G ./testing.vmdk --force
For shrinking on ESX 3.0x use the VMWare Converter (download from the VMware Website for freee). Point the source and destination to the same ESX Host.
If you receive an error one parameter was incrorrect the size might be smaller as the original size!
If you have blanks in the file or directoryname, mask the full path with '
vmkfstools -i
To export or clone a virtual disk from VMFS
vmfsktools -i
Example:
Copy from one vmfs to another:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmfs/volumes/production/testvmnew2.vmdk
vmkfstools -i /vmfs/volumes/esxpublic/testvm2.vmdk /vmfs/volumes/production/testvmnew2.vmdk
Export to ext3 partition:
Source=/vmfs/volumes/esxpublic/testvm2.vmdk
Destination=/vmimages/testvm2.vmdk
vmkfstools -i /vmfs/esxpublic/testvm2.vmdk -d 2gbsparse /vmimages/testvm2.vmdk
vmkfstools -E
Rename files associated with a specified virtual disk
vmkfstools -U
Delete Virtualdisk
Delete files associated with the specified virtual disk.
vmkfstools -c 4000M ./file.vmdk
To create a new empty virtual disk
vmkfstools -c 300G -a lsilogic /vmfs/volume/vmfslabel/directory/newdisk.vmdk
or in current directory
vmkfstools -c 300G -a lsilogic ./newdisk.vmdk
This command is very useful because you can use user-friendly names for the disks
For further options enter man vmkfstools
Reboot the VM. First try a nice shutdown, then if necessary force a shutdown before reboot
reboot
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx start
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx start
start() = 1
Power on the VM
start
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx stop trysoft
stop(trysoft) = 1
Shutdown/halt the VM. First try a nice shutdown, then if necessary force a shutdown. Finally power off.
shutdown
vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx suspend
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx suspend
suspend() = 1
Suspend the VM
suspend vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx hassnapshot
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() =
Query if VM has a snapshot
snapshot vmware-cmd createsnapshot name description quiesce memory
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx createsnapshot "snap1" "before patching" quiesce memory
createsnapshot(snap1 before patching quiesce memory) = 1
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx hassnapshot
hassnapshot() = 1
Quiesce will quiesce file system writes
Memory will grab the memory state (will lose pings during this)
createsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx revertsnapshot
Sample:
[root@vs03 root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx revertsnapshot
revertsnapshot() = 1
Revert to previous created snapshot (you loose the current VM state!)
revertsnapshot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx removesnapshots
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx removesnapshots
removesnapshots() = 1
Remove previous created snapshots (you keep the current VM state!)
removesnapshots vmware-cmd -s register vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s register /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
register(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Register VM (add to inventory)
register vmware-cmd -s unregister vmfs/volume/vmfslabel/VMName/VMName.vmx
Sample:
[root@esxhost root]# vmware-cmd -s unregister /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx
unregister(/vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx) = 1
Unregister VM (add to inventory)
unregister vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx answer
Sample:
[root@esxhost root]# vmware-cmd /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a/printer/printer.vmx answer
No questions pending.
In this case there is no pending input request. If there is any pending input request you will be promptet for the answser.
answer pending request for userinput
o delete and recreate a virtual switch and Service Console from the command line:
Note: On your system the vswif, vmnic, vSwitch numbers and network settings are different.
No comments:
Post a Comment