VMWARE Commandline

Reviews
Shared by: hao nguyen
Stats
views:
2675
rating:
not rated
reviews:
0
posted:
3/5/2009
language:
English
pages:
0
esxcfg VMware console tool esxcfg is a new management tool from VMware. Be careful, some commands could crash your system! esxcfg tool Management in the console esxcfg-rescan esxcfg-rescan vmhba1 Rescan vmhbas esxcfg-rescan vmhba2 esxcfg-mpath -l VMware ESX Server multipathing information Disk vmhba1:3:6 /dev/sdu (225280MB) has 2 paths and policy of Most Recently Used FC 2:1.0 210000e08b0246af<->201400a0b81167e2 vmhba1:3:6 On active preferred FC 4:1.0 210000e08b02e4a0<->201500a0b81167e2 vmhba2:3:6 Standby Multipathing of HBAS listing and configure esxcfg-vmhbadevs -m See the relationship between vmhba and devnames. This produces an output like so: vmhba1:3:6:1 /dev/sdu1 44ebf538-51cc7998-2525-00145e1b556a vdf /vmfs/volumes/44ebf538-51cc7998-2525-00145e1b556a 230424576 44748800 185675776 19% /vmfs/volumes/CoreDomain ls /vmfs/devices/disks/ list all your disks/luns like so:vmhba0:0:0:0 vmhba0:1:0:0 vmhba1:2:0:0 vmhba1:3:0:0 vmhba1:4:0:0 vmhba1:5:0:0 vmhba1:6:0:0 vml.02000000003343453035595041202020203731303638315430535831373334 vml.0200000000334345303634504b202020203731303545464853535831373334 vml.0200000000334345304150415420202020373131384b51305a535831373334 Relationship between Vmhbas and devname Not an esxcfg command but very useful vml.0200000000334345304244584e202020203731313835485231535831373334 vml.0200000000334345304446543230303030373132314e4c5a57535431373334 vml.02000000005546413350323330375352544d414e333336 vml.02000000005546413350323330375442444d414e333336 You can then use fdisk to work out if the disks are blank of partitioned with: fdisk /vmfs/devices/disks/vmhba1:5:0:0 Identify the LUN Disk and Partition vmhbax:y:z:v x=Hostbusadapter (0=mostly internal SCSI Adapter, 1=mostliy fibrechannel 1...x) y=LUN z=Disk v=Partition esxcfg-firewall esxcfg-firewall --openPort esxcfg-firewall --closePort port: Apllication Port Protocol:tcp or udp Direction: in or out name: Descriptive name of rule esxcfg-firewall -q to query settings Example: Firewall settings esxcfg-firewall --openPort 14247,tcp,out,IBMDirector You cannot configure unsupported services through the VI Client. esxcfg-vmhbadevs vmhba0:0:0 vmhba0:1:0 vmhba0:2:0 /dev/sda /dev/sdb /dev/sdc VMkernel storage devices to service console devices Map of VMkernel storage devices to service console devices esxcfg-vswitch esxcfg-vswif -i 192.168.1.55 -n 255.255.255.0 vswf0 Creates and updates virtual machine network settings Change IP Address and Subnetmask vmkpcidivy vmkpcidivy is deprecated, it is only provided for compatibility with vmkpcidivy -q vmhba_devs vmkpcidivy is depreciated Example: [root@esx001 root]# vmkpcidivy -q vmhba_devs vmhba0:0:1 /dev/sdc vmhba0:0:2 /dev/sdd vmhba1:0:0 /dev/sde vmhba2:0:0 /dev/sda vmhba2:1:0 /dev/sdb vmkfstools manage VM Disks This tool is from VMware. It is used for Virtual-disk and VMFS management. Be aware, always use Virtual Center GUI to create VMFS Volumes. Otherwise you will end up with an unaligned VMFS partition and decreased performance. 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 -d diskformat 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 vmware-cmd Command line tool vmware-cmd VM Management in the console vmware-cmd -l Sample: vmware-cmd -l 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 vmware-cmd /vmfs/volume/vmfslabel/VMName/VMName.vmx getstate Sample: getstat Retrieve power state of the VM: off, on, suspended, stuck vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx reset trysoft Sample: reboot Reboot the VM. First try a nice shutdown, then if necessary force a shutdown before reboot vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx start Sample: startPower on the VM vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop hard Sample: shutdown Shutdown/halt the VM. First try a nice shutdown, then if necessary force a shutdown. Finally power off. vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx suspend Sample: suspendSuspend the VM vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx hassnapshot Sample: hassnapshots Query if VM has a snapshot vmware-cmd createsnapshot name description quiesce memory Sample: createsnapshot Quiesce will quiesce file system writes Memory will grab the memory state (will lose pings during this) vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx revertsnapshot Sample: reverttosnapshot list getstat reboot start shutdown suspend snapshot createsnapshot revertsnapshot Revert to previous created snapshot (you loose the current VM state!) vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx removesnapshots Sample: removesnapshot Remove previous created snapshots (you keep the current VM state!) vmware-cmd -s register vmfs/volume/vmfslabel/VMName/VMName.vmx Sample: register Register VM (add to inventory) vmware-cmd -s unregister vmfs/volume/vmfslabel/VMName/VMName.vmx Sample: unregister Unregister VM (add to inventory) vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx answer Sample: answer answer pending request for userinput removesnapshots register unregister answer Shortcut key combinations in the Console Key or key combination Ctrl+A Ctrl+C Ctrl+D Ctrl+E Ctrl+H Ctrl+L Ctrl+R Ctrl+Z ArrowLeft and ArrowRight ArrowUp and ArrowDown Shift+PageUp and Shift+PageDown Tab Tab Tab Function Move cursor to the beginning of the command line. End a running program and return the prompt. Log out of the current shell session, equal to typing exit or logout. Move cursor to the end of the command line. Generate backspace character. Clear this terminal. Search command history. Suspend a program. Move the cursor one place to the left or right on the command line, so that you can insert characters at other places than just at the beginning and the end. Browse history. Go to the line that you want to repeat, eventually edit details, and press Enter to save time. Browse terminal buffer (to see text that has "scrolled off" the screen). Command or filename completion; when multiple choices are possible, the system will either signal with an audio or visual bell, or, if too many choices are possible, ask you if you want to see them all. Shows file or command completion possibilities. Linux and VMware configuration files Important Linux Files and Directories Color blue red white pink cyan yellow green flashing red Character nothing / * @ = | File type directories compressed archives text files images links devices executables broken links File type regular file directory executable file link socket named pipe /dev/fd0 /etc/bashrc Address floppy disk drive The system default $PS1 is defined here. It is a good idea to change "\W" to "\w" here to always see the full path while logged on the Service Console. Scheduled Tasks are stored in this file more /etc/ Lists the directories that the server can export. The /etc/exports file contains an entry for each directory that can be exported to NFS clients. This file is read automatically by the exportfs command. If you change this file, you must run the exportfs command before the changes can affect the way the daemon operates. Examples 1. To export to netgroup clients, enter: /etc/exports 2. 3. /usr -access=clients To export to the world, enter: 4. 5. /usr/local To export to only these systems, enter: 6. 7. /usr2 -access=hermes:zip:tutorial To give root access only to these systems, enter: 8. 9. /usr/tps -root=hermes:zip To convert client root users to guest UID=100, enter: 10. /usr/new -anon=100 11. To export read-only to everyone, enter: 12. /usr/bin -ro 13. To allow several options on one line, enter: 14. /usr/stuff -access=zip,anon=-3,ro This file defines the local and remote filesystems which are mounted at ESX Server boot. Example: 1. Add entry to local hosts (/etc/hosts) for MS host 2. Create directory where you wish the mount point with mkdir 3. Run smbclient ?I -U user ?L NetBIOSComputername to check you can see the shares see here 4. Add an entry to /etc/fstab //server/share /mountdir smbfs username=user,password=pass 0 0 /etc/fstab 5. Mount the remote file system with mount /mountdir 6. Change directory into mount point and the directory will no longer be empty but will appear just like a mapped drive. To avoid cleartext passwords in this file you can place this informatin in a secured hidden file. echo username=user > .smbcreds echo password=pass >> .smbcreds chmod 600 .smbcreds The entry in fstab: //server/share /mountdir smbfs ip=ipaddress,credentials=/root/.smbcreds,noauto 0 0 /etc/ftpusers lists all users not allowed to connect with FTP List of security groups Example: root:x:0:root bin:x:1:root,bin,daemon daemon:x:2:root,bin,daemon sys:x:3:root,bin,adm adm:x:4:root,adm,daemon /etc/group /etc/hosts As your machine gets started, it will need to know the mapping of some hostnames to IP addresses before DNS can be referenced. This mapping is kept in the /etc/hosts file. In the absence of a name server, any network program on your system consults this file to determine the IP address that corresponds to a host name. The leftmost column is the IP address to be resolved. The next column is that host's name. Any subsequent columns are alias for that host. Example: /etc/init.d/ 127.0.0.1 localhost.localdomain localhost 10.30.10.52 esx002 This directory contains the actual start-up scripts. Here you can change the amount of virtual terminals available on the Service Console. Default is 6, but you can go up to 9. This file is read by the init process and specifies the run level to be used by the service console. The line that states the run level will look something like this. id:3:initdefault: The default runlevel for ESX is 3 The init process then works through the start up scripts in the appropriate diectory. For run level 3, this directory would be /etc/rc.d/rc3.d The file also starts up the virtual terminals on the ESX server mingetty tty2 through mingetty tty5. The mingetty process is minimum getty. File which shows ESX and vmnix version Example: VMware ESX Server 2.5.1 Kernel 2.4.9-vmnix2 on an i686 /etc/inittab /etc/issue /etc/lilo.conf /etc/logrotate.conf /etc/logrotate.d/ /etc/modules.conf Lilo.conf is the text file to describe the OS to boot. This text file is compiled into a binary file that is actually used by LILO. This is the main configuration file for log file rotation program. It defines the defaults for log file rotation, log file compression, and time to keep the old log files. Processing the contents of /etc/logrotate.d/ directory is also defined here. This directory contains instructions service by service for log file rotation, log file compression, and time to keep the old log files. For the three vmk* files, raise "250k" to "4096k", and enable compression. This file contains a list of devices in the system available to the Service Console. Usually the devices allocated solely to VMs, but physically existing on the system are also shown here in the commented-out ("#") lines. This is an important file for root and administrators. This text file describes the devices that are assigned to the service console by vmkpcidivy. Identifies interface eth0 and aliases alias eth0 e1000 alias eth1 e1000 options e1000 Speed=100 /etc/ntp.conf This file configures the NTP daemon. Usable public NTP servers in Finland are fi.pool.ntp.org, elsewhere in Europe europe.pool.ntp.org. You should always place two to four NTP servers to ntp.conf file. Due to the nature of *.pool.ntp.org, you should just have the same line four times in the configuration file. Check www.pool.ntp.org for a public NTP server close to you. Remember to change the service to autostart at runlevel 3. List of security users. When we add a user with either the MUI or a command line tool such as useradd, we are adding to this text file. Example: /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin /etc/profile.d/colorls.sh /etc/rc2.d/ /etc/rc3.d/ /etc/rc.d/rc.local Command "ls" is aliased to "ls --colortty" here. You can comment-out ("#") this line. This directory contains the K(ill) and S(tart) scripts for the default runlevel 2. This directory contains the K(ill) and S(tart) scripts for the default runlevel 3. The services starting with "S" are started on this runlevel, and the services Starting with "K" are killed, i.e. not started.. The number after the K or S determines the order in which the scripts will run. S scripts will run in ascending order K scripts will run in descending order This file is for server local customizations required at the server bootup. Potential additions to this file are public/shared vmfs mounts. The DNS name server settings, This file does not need to be present if you are not using DNS. /etc/resolv.conf Example: nameserver 10.20.10.21 nameserver 10.20.10.22 Password file Skeleton directory ? new home directories take copies of the files stored here. /etc/shadow /etc/skel This directory contains all the SSH daemon configuration files, public and public keys. The defaults are both secure and flexible and rarely need any changing. The only exception is a change to /etc/ssh/sshd_config file if you want to restrict logins for root user. Quick way to restart the ssh daemon. Use full path to do this. /etc/init.d/sshd restart /etc/ssh/ssh_config Text file with the configuration of SSH client. /etc/ssh/sshd_config Text file with the configuration file for SSH daemon. An important setting in this file is PermitRootLogin=Yes/No. You can quickly check this with a grep on the file. grep permit /etc/ssh/sshd_config ~/.ssh/known_hosts Allow or deny SSH for specified users: add the following lines to the sshd_config file AllowUsers user1 user2 user3 .... Deny Users user1 user2 user3 .... A text file that stores the RSA keys for known hosts. If we rebuild a host and then reconnect to it over SSH we may be prevented if the known_hosts file has cached the old key. I think SCP (secure copy) uses RSA keys as well as SSH sessions. Note this file is maintained on a per-user basis. /etc/ssh/ /etc/ssh/sshd_config Text file containing hostname and default gateway. /etc/sysconfig/network Example: NETWORKING=yes HOSTNAME=esx002 GATEWAY=10.20.0.1 IP, mask and device name. The text file contains IP configuration for interface eth0, which is reserved for the service console. Change the console IP Address here /etc/sysconfig/networkscripts/ifcfg-eth0 Example: DEVICE=eth0 BOOTPROTO=static IPADDR=10.20.10.52 NETMASK=255.255.0.0 ONBOOT=yes This file configures what things are logged and where. Some examples are given below: *.crit /dev/tty12 This example logs all log items at level "crit" (critical) or higher to the virtual terminal at tty12. You can see this log by pressing [Alt]-[F12] on the console. *.=err /dev/tty11 /etc/syslog.conf This example logs all log items at exactly level "err" (error) to the virtual terminal at tty11. You can see this log by pressing [Alt]-[F11] on the console. *.=warning /dev/tty10 This example logs all log items at exactly level "warning" to the virtual terminal at tty10. You can see this log by pressing [Alt]-[F10] on the console. *.* 10.30.10.52 /etc/vmware/ This example forwards everything (all syslog entries) un-encrypted to another (central) syslog server. Pay attention to that server's security. This directory contains the most important vmkernel configuration files. This text file maps device names (example above) to modules and their PCI addresses. Note that the devnames.conf file contains SCSI devices and NIC devices. /etc/vmware/devnames.conf /etc/vmware/hwconfig 002:14.0 megaraid vmhba0 005:04.1 nic vmnic0 011:07.0 nic vmnic1 012:08.0 nic vmnic2 grep ?i vmnic /etc/vmware/hwconfig nic is which team Maps ESX virtual switch names to device names. network0.name = network0.device network1.name = network1.device network2.name = network2.device "VM2Gigabit" = "vmnic2" "VirtualSwitch1" = "vmnet_1" "InternetSwitch" = "vmnic1" Finding which /etc/vmware/netmap.conf /etc/vmware/vm-list A file containing a list of registered VMs on this ESX Server. /etc/vmware/vmwaredevices.map /etc/vmware/vmkconfig Like hardware compatibility list. The file contains a list of ESX supported devices. Modify the vmware-devices.map.local file to select different devicedrivers (the file is not modified on upgrades). The vmware-devices.map.local file supercedes the vmware-devices.map file. This is a text file which stores vmkernel configuration, like an INI file or registry key. The important fact to note is that this file does not exist until you make an edit away from the default setting. /etc/xinetd.conf This is the main and defaults setting configuration file for xinet daemon. Processing the contents of /etc/xinetd.d/ directory is also defined here. The daemon itself is stored in /usr/sbin/xinetd This directory contains instructions service by service for if and how to start the service. Of the services here, vmware-authd, wu-ftpd, and telnet are most interesting to /etc/xinetd.d/ us. Two of the most interesting parameter lines are "bind =" and "only_from =", which allows limiting service usage. A text file that can be checked to see what the service console NIC is doing. The speed /proc/net/NICfamily/eth0.info of the console NIC specified in the file modules.conf can be confirmed by this file. A text file that can be checked to see what swap the service console is using. The output contains a priority which shows which swap device will be used first before the other(s). Useful to determine if swap space is getting used and if there is more than 1 swap. Remember this is vmnix (service console) swap, not VMkernel. The VMkernel swap is in one or more files on a VMFS volume (hence the strong recommendation that even when using a SAN, a vmfs volume is created on direct attached storage to allow local swap). Text file with discovered PCI devices /proc/swaps /proc/vmware /proc/vmware/pci /var/log/ This directory contains all the log files. VMware's log files start with letters "vm". The general main log file is "messages". Network The findnic command lets you send network traffic from a specified network adapter so you can observe the LEDs on the adapters and see which physical adapter is associated with that device name. The format of the command is findnic -f Do a flood ping. -i Send pings at specified interval. findnic Example: findnic -f vmnic1 10.2.0.5 10.2.0.4 findnic -i 3 vmnic1 10.0.0.1 192.168.1.10 The above command will send ICMP echo requests to 192.168.1.10 every 3 seconds. The NIC allocated to the VMKernel does not have an IP address. We need to give an IP address temporary to this NIC, it is specified as the first IP parameter. The second IP is the ICMP destination Network Set and display the network interface configuration information for devices used by the service console. To set/change the IP-address Example: ifconfig eth0 10.3.44.10 netmask 255.255.255.0 ifconfig Can also be used to bring interfaces up or down ifconfig eth0 up ifconfig lo down Ifup eth0 Brings interface �eth0� up Ifdown eth0 Takes interface �eth0� down. Displays the option of a loaded module. modinfo modinfo e1000 Will produce a list of possible setting on the Network adapter as flow control With vmkload_mod -l you can list all loaded modules kudzu This is the RedHat's tool to detect and configure hardware: adding new and removing old. When you run kudzu, or system runs it at bootup, be careful. Kudzu might offer to remove hardware you have dedicated solely to the VMs. Know your hardware and configuration. It might be a good idea to refer to /etc/modules.conf file before running kudzu. A safe action to select in kudzu is "Do nothing". Select it when in doubt. shows information about all loaded modules Lists drivers loaded for the service console linux. Remember this command differs from the vmkload_mod utility which shows the modules loaded for the VMkernel. Module Size Used by Tainted: PF vmnixmod 177056 121 e1000 68456 0 (unused) usb-uhci 21220 0 (unused) usbcore 50112 1 [usb-uhci] megaraid2 32928 6 The same information can be found by cat /proc/modules List PCI devices H1 uses direct HW access -n shows PCI vendor and device codes -t Print tree of PCI Devices -tv for verbose tree -v verbose mode -vv very verbose mode -M never use.It might crash ESX Server Also check the file /proc/pci Modify the NIC settings Example: mii-tool 100baseTx-FD eth0 (This sets the serviceconsole NIC to 100 Mbps and Full) mii-tool 100baseTx-FD vmnic1 (This sets the Virtual Machine NIC to 100 Mbps and Full) You could also use the MUI as well lsmode lspci mii-tool netconfig netstat Network configuration setup program Shows currently active network connections Modify or print routingtable route route Prints routing table route del � net default Deletes the default gateway route add � net default gw 10.20.0.1 Adds a new default gateway View and connect SMB (Microsoft networking) hosts. Test connection before updating /etc/fstab file. smbclient smbclient � 192.168.4 � username � computername I U L Microsoft Network shares Will list the available showmount showmount lists all the clients that have remotely mounted a filesystem from host. -d list directories that have been remotely mounted by clients -a print all remote mounts in the format hostname:directory where hostname is the name of the client and directory is the root of the filesystem that has been mounted -e print the list of exported filesystems Allows changing of NIC, region, firewall, mouse, keyboard setup System Performance Services Tasks Installation This service console tool displays a table showing which daemons are enabled for the run levels for the vmnix operating system. ntpd 0:off 1:off 2:on 3:on 4:on 5:off 6:off syslog 0:off 1:off 2:on 3:on 4:on 5:off 6:off snmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off If we wanted to change a service so that it is enabled for a particular run level, then we chkconfig --list can use chkconfig �level. chkconfig --level 1 ntpd on The above command would turn on ntpd for run level 1, this would not affect the run levels that ntpd was already set for. So in this example, the ntpd run levels would be ntpd 0:off 1:on 2:on 3:on 4:on 5:off 6:off Changes the owner user and optionally owner group of a directory, or a file. Optionally this command works recursively with parameter "-R". The assignment parameter is of type "user.group", or just "user". Some examples are given below: chown -R helpdesk.vmadmins /vmfs /data Recursively change the user-owner, and the group-owner of specified files/directories to userid.groupid. chown chown helpdesk.vmadmins /vmfs/local/* chown -R root /data/vmware chown root.vmadmins /etc/modules.conf clear Equivalent of CLS command in MS-DOS and in Windows command prompt. System Performance Services Tasks Installation Schedule -tasks The crond service must be running. To determine if the service is running, use the command /sbin/service crond status Each line in the /etc/crontab file represents a task and has the format: minute hour day month dayofweek command Example: 42 4 1 * * root run-parts /etc/cron.monthly minute - any integer from 0 to 59 hour - any integer from 0 to 23 day - any integer from 1 to 31 (must be a valid day if a month is specified) month - any integer from 1 to 12 (or the short name of the month such as jan or feb) dayofweek - any integer from 0 to 7, where 0 or 7 represents Sunday (or the short name of the week such as sun or mon) command - the command to execute (the command can either be a command such as ls /proc >> /tmp/proc or the command to execute a custom script) If a cron task needs to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d directory. All files in this directory use the same syntax as /etc/crontab. Refer to following example for examples. # record the memory usage of the system every monday # at 3:30AM in the file /tmp/meminfo 30 3 * * mon cat /proc/meminfo >> /tmp/meminfo # run custom script the first day of every month at 4:10AM 10 4 1 * * /root/scripts/backup.sh For any of the above values, an asterisk (*) can be used to specify all valid values. For example, an asterisk for the month value means execute the command every month within the constraints of the other values. A hyphen (-) between integers specifies a range of integers. For example, 1-4 means the integers 1, 2, 3, and 4. A list of values separated by commas (,) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers. The forward slash (/) can be used to specify step values. The value of an integer can be skipped within a range by following the range with / . For example, 0-59/2 can be used to define every other minute in the minute field. Step values can also be used with an asterisk. For instance, the value */3 can be used in the month field to run the task every third month. Any lines that begin with a hash mark (#) are comments and are not processed. As shown in the /etc/crontab file, it uses the run-parts script to execute the scripts in the /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly directories on an hourly, daily, weekly, or monthly basis respectively. The files in these directories should be shell scripts. Users other than root can configure cron tasks by using the crontab utility. All user-defined crontabs are stored in the /var/spool/cron directory and are executed using the usernames of the users that created them. To create a crontab as a user, login as that user and type the command crontab -e to edit the user's crontab using the editor specified by the VISUAL or EDITOR environment variable. The file uses the same format as /etc/crontab. When the changes to the crontab are saved, the crontab is stored according to username and written to the file /var/spool/cron/username. The cron daemon checks the /etc/crontab file, the /etc/cron.d/ directory, and the /var/spool/cron directory every minute for any changes. If any changes are found, they are loaded into memory. Thus, the daemon does not need to be restarted if a crontab file is changed. crontab With this 'disk dump' command you can create ISO images and floppy images. You can also use it to create imagefiles of partitions and whole disks. Below are some example commands: dd if=/dev/cdrom of=/local/suse90pro-dvd1.iso bs=2048 dd if=/dev/cdrom of=/local/w2003srv.iso bs=2048 The above two examples create an ISO image of a CD/DVD. You can safely ignore the error message usually shown at the end of the media. dd if=/dev/fd0 of=/local/bootfloppy1.img bs=1440k This command creates a floppy image quickly. You can also use the freeware Emt4win utility for Windows to create floppy images dd dd if=/dev/fd0 of=/local/bootfloppy2.img bs=512 This might be a bit slower version of the above example. This tool can be used to create an additional swap file. For example, if we did not allocate a big enough swap partition for the service console during ESX installation, we can create one now in a file of 64MB. dd if=/dev/zero of=/swapfile bs=1M count=64 If we did add a swap file, we would need to make sure it is started when ESX starts. Therefore, an entry in /etc/fstab would be needed as this file describes the local and remote file systems to mount at boot. The total amount of service console swap space is the sum of the swap partition and any swap files that are active. See also: mkswap, swapon, swapoff Package manager for .deb packages (Debian distribution).Technical difference to rpm is very small. Mostly handled through apt, dselct, aptitude, gnome-apt, synaptic, kpackage. Shows free memory in the service console. The "-m" switch specifies to display the results in megabytes Search for a string from standard input or from a file. This is a powerful command. Adds a new group to the Service Console. It is recommended to use one non-root group for VM admins and add operator/admin users there. To create that group, enter the following command: groupadd -g 7777 vmadmins groupadd Create a group with groupid number 7777. This number is an arbitary number. For practical (not explained here) reasons this number should have four digits. dpkg free -m grep gzip|gunzip halt These commands compress and decompress files. The recommended and default extension is .gz. The compression is quite fast, and files are quite small. Decompression is fast. Does a nice halt on the system. Does "Force Power Off" for the VMs. mkswap A command that must be run against a newly created swap file in Displays the option of a loaded module. modinfo e1000 Will produce a list of possible setting on the Network adapter as flow control With vmkload_mod -l you can list all loaded modules List open files Pipe the results into grep to check for open ports modinfo lsof lsof |grep IPv4.\*LISTEN This is the RedHat's tool to detect and configure hardware: adding new and removing old. When you run kudzu, or system runs it at bootup, be careful. Kudzu might offer to remove hardware you have dedicated solely to the VMs. Know your hardware and configuration. It might be a good idea to refer to /etc/modules.conf file before running kudzu. A safe action to select in kudzu is "Do nothing". Select it when in doubt. shows information about all loaded modules Lists drivers loaded for the service console linux. Remember this command differs from the vmkload_mod utility which shows the modules loaded for the VMkernel. Module Size Used by Tainted: PF vmnixmod 177056 121 e1000 68456 0 (unused) usb-uhci 21220 0 (unused) usbcore 50112 1 [usb-uhci] megaraid2 32928 6 The same information can be found by cat /proc/modules List PCI devices H1 uses direct HW access -n shows PCI vendor and device codes -t Print tree of PCI Devices -tv for verbose tree -v verbose mode -vv very verbose mode -M never use.It might crash ESX Server Also check the file /proc/pci Displays the manual page for a specified command. Press the spacebar to go to the next screen of text. Press q to exit from the display when you are finished. man man cat Display the manual page for the command cat. Display the contents of a specified file one screen at a time. Use the spacebar to move forward through the file a screen at a time; use the Enter key to move forward through the file one line at a time. more more myfile Display the contents of the file myfile. This command takes an NTP server as a parameter and synchronizes the clock once. This command doesn't work when local NTP daemon is running. Example: ntpdate europe.pool.ntp.org kudzu lsmode lspci ntpdate passwd Changes the password for the userid entered as a parameter for the command. Only root can change the password for other users. They can only change their own password with command "passwd". Userids are disabled by default. They are activated by setting a password for them. An example command for root to set a password is the following command: passwd johndoe Finds the PID of a named process. pidof pidof vmware-ccagent Show running processes in the service console. ps -A ps � eaf ps -eaf |grep vmware-serverd ps -efw is useful as the -w indicates wide format, so we can see the full directory path to the vmx file. Show process tree with PIDs and ancestors Show the path to the present working directory. Prints the manual page for a command or a configuration file entered as a parameter to this command. Change process priority. If there were many VMs running concurrently, it may be necessary to temporarily raise the priority of the MUI in order to complete administrative tasks renice [-n increment][ -g| -p| -u] ID... -n increment Specify how the system scheduling priority of the specified process or processes is to be adjusted. The increment option-argument is a positive or negative decimal integer that will be used to modify the system scheduling priority of the specified process or processes. Positive increment values cause a lower system scheduling priority. Negative increment values may require appropriate privileges and will cause a higher system scheduling priority. -p Interpret all operands (or just the pid arguments in the obsolescent version) as unsigned decimal integer process IDs. renice ps � |grep vmware eaf renice -p renice -p To reset the PID of these processes back to their defaults, use renice again to set the priority to zero. renice -n 19 12345 # 12345 represents the PID of your process You will increase the nice value all the way to 39. In fact, the 19 could be any larger number as well nice values max out at 39 either way. And in case you are thinking your program will grind to a halt at a nice value of 39, you needn't worry. In fact, changing the nice value all the way from 20 to 39 has a surprisingly small effect on the activity of the process, but it's the best we can do. ps pstree -ph pwd reboot Red Hat Package Manager (automating software binaries and remembers what files are needed so the software will run properly RPM tracks dependencies and will inform you if additional packages are needed. There is a database of packages and what files they use. If you do an uninstall it will be checked if other packages will also use this files. If you try to uninstall a package that other packages are still dependent upon, RPM informs you about it and refuses to do the uninstall. Single files can not be retrieved, you can only install the whole package or nothing. Install without output: rpm -i packagename or rpm --install packagename Install with verbose output: rpm -ivh packagename Update a package: rpm -U packagename or rpm --update packagename Get a list of all installed packages: rpm -qa rpm Get the version of an installed package: rpm -q package Find out to whiche package a file belonges: rpm -qf Filename Display information about a package: rpm -qi packagename Show the files that will be installed: rpm -qpl packagename To initialize the RPM Database: Careful do only initialize the database if it wasn't initialized before!! rpm --initdb Of course the database doesn't know anything about prior installed packages and in this cases you can install some packages without checking the dependency (for already installed packages. RedHat-made tool for daemon (service) starting/stopping/restarting/status querying. Syntax is "service daemon name [start|stop|restart|status]". Alternate to this command, which works with all Linuces is to call the script directly, like /etc/init.d/httpd.vmware restart, /etc/init.d/xinetd restart, or /etc/init.d/sshd restart. service --status-all This lists all the service daemons and their status. We can find running services by looking for the running status service � -status-all |grep running would produce an output similar to the following: crond (pid 1423) is running httpd (pid 1486 1482 1479) is running service syslogd (pid 1136) is running sshd (pid 1208) is running To avoid unnecessarily rebooting an ESX server after making certain configuration changes, we can frequently just restart the appropriate daemon. For example we could restart the Apache web server for the MUI with the command: service httpd.vmware restart and we can also check a named service running status with service httpd.vmware status Great way to do orderly restart of vmnix network configuration. service network restart setup shutdown ssh Allows changing of NIC, region, firewall, mouse, keyboard Generic command for shutting down or rebooting the system. -h Halt after shutdown -r Reboot after shutdown Secure shell Login to remote Linux (ESX) machine. To work with ssh I recommend to setup SSH Key authentication between linux (ESX) servers instructions Never need to enter password again! Switch user. By default, this allows you to log in as the root user if you know the root user's password. You can also use the command to log in as any other user if you know the appropriate user name and password. Enter the command, then enter the password when prompted. su User2 Log in as User2. Enables swap file for service console Disables swap file for service console Shows the running processes in the service console and lists the top consumers of CPU time. Outputs details of the server as shown Example: Linux esx002 2.4.9-vmnix2 #1 Thu Mar 17 16:09:37 PST 2005 i686 unknown su swapon swapoff top uname -a Adds a new user to the Service Console with status disabled. To create an account for the new admins, enter the following commands: useradd -c "VMware ESX Server operator" helpdesk Create a single userid, which will be able to operate all of the VMs. useradd useradd -g 7777 johndoe Create a userid, and make groupid 7777 (vmadmins) as its primary group. useradd -g 7777 -c "Kari Mattsson" mattkar2 Create a userid, and make groupid 7777 (vmadmins) as its primary group. Changes settings for a user. Usually used for user group manipulation. usermod usermod -G wheel mattkar2 Performance information. Linux command vmstat vmstat 3 10 Runs the tool every 3 seconds for 10 times and then exit. Polls on the command the running status watch cat /proc/vmware/mem Display dynamically the memory usage watch watch -d cat /proc/vmware/mem The -d option highlights changes --interval=n will change the refresh rate For more information visit the Business to Virtual Website Command Line Guide cat View filecontent Concatenate file from start to standard output (terminal screen by default). Usually takes filename as a parameter. cat > file (Enter text at command line and then CTRL-D to write to file.) cd Change directories. cd /home/user Change to the directory /home/user (the home directory for a user with the user name user). cd .. Go up one level from the current directory. Change directories. cd /home/user Change to the directory /home/user (the home directory for a user with the user name user). cd .. Go up one level from the current directory. cd Change to your user homedirectory chmod This command is the main command for changing file modes (permission). Like chown, it can do things recursively with parameter "-R". If you use ls -l you get a list of directories and files with there permission d rwx r-x r-x The first character states if it is a directory (d) or a file (-) The next characters are split in groups of 3 characters and stand (in this order) for: owner group everyone You can add the sum of rights: 4= read 2= write 1= execute 5 will be read and execute Changes file permission. We can use either letters or numeric equivalency when setting permissions. We set permission for 3 principals, the user, the group and others (ugo). If you are from a Windows background then don?t confuse ?o? with owner. #chmod u+rx,g+r,o+r file.txt Note that using + or ? indicates we are adding to or removing from existing permission. If we wish to reset the permission we use ?=? to explicitly set the object permissions. #chmod u=rx,g=r,o=r file.txt yields r-xr?-r-Sometimes you will see a chmod using ?a? to specify all (user, group & other), so we could quickly set read permissions by #chmod a-wx,a+r file.txt yields r?-r-?r-A more common way to set permission is using chmod is using numeric equivalent values (4,2,1 for r,w,x) and permutations thereof. chmod 777 windows2k.vmx set perms to rwxrwxrwx chmod 754 windows2k.vmx set perms to rwxr-xr-- (default) Watch for chmod commands with 4 digits, e.g. chmod 0754. This refers to additional attributes chmod -R 0775 /vmfs /data chmod u=rwx,g=rwx,o=r /vmfs/freebsd462/* chmod g+rwx /vmfs/vm007/* chmod -R u+rwx,g=r,o-rwx /var/log/* chmod u=rw,g=rw,o=r /etc/modules.conf chmod 664 /etc/modules.conf chmod u=rw,g=rw /vmfs/*/*.dsk (It appears, that this example works rather nicely. Note, that those VMs which are powered-on, have their .dsk files locked. ) Change mode (permissions) for a specified file, group of files or directory. chmod 755 *.vmx Set permissions on all files in the current directory that end with .vmx to be -rwxr-xr-x. chmod 660 nvram Set permissions on the file nvram in the current directory to be -rw-rw----. This command is the main command for changing file modes (permission). Like chown, it can do things recursively with parameter "-R". If you use ls -l you get a list of directories and files with there permission d rwx r-x r-x The first character states if it is a directory (d) or a file (-) The next characters are split in groups of 3 characters and stand (in this order) for: owner group everyone You can add the sum of rights: 4= read 2= write 1= execute 5 will be read and execute Changes file permission. We can use either letters or numeric equivalency when setting permissions. We set permission for 3 principals, the user, the group and others (ugo). If you are from a Windows background then don?t confuse ?o? with owner. #chmod u+rx,g+r,o+r file.txt Note that using + or ? indicates we are adding to or removing from existing permission. If we wish to reset the permission we use ?=? to explicitly set the object permissions. #chmod u=rx,g=r,o=r file.txt yields r-xr?-r-Sometimes you will see a chmod using ?a? to specify all (user, group & other), so we could quickly set read permissions by #chmod a-wx,a+r file.txt yields r?-r-?r-A more common way to set permission is using chmod is using numeric equivalent values (4,2,1 for r,w,x) and permutations thereof. chmod 777 windows2k.vmx set perms to rwxrwxrwx chmod 754 windows2k.vmx set perms to rwxr-xr-- (default) Watch for chmod commands with 4 digits, e.g. chmod 0754. This refers to additional attributes chmod -R 0775 /vmfs /data chmod u=rwx,g=rwx,o=r /vmfs/freebsd462/* chmod g+rwx /vmfs/vm007/* chmod -R u+rwx,g=r,o-rwx /var/log/* chmod u=rw,g=rw,o=r /etc/modules.conf chmod 664 /etc/modules.conf chmod u=rw,g=rw /vmfs/*/*.dsk (It appears, that this example works rather nicely. Note, that those VMs which are powered-on, have their .dsk files locked. ) Change mode (permissions) for a specified file, group of files or directory. chmod 755 *.vmx Set permissions on all files in the current directory that end with .vmx to be -rwxr-xr-x. chmod 660 nvram Set permissions on the file nvram in the current directory to be -rw-rw---- clear cp crontab -e Equivalent of CLS command in MS-DOS and in Windows command prompt. cp oldfile newfile Make a copy of the file oldfile in the current directory. The copy is named Schedule -tasks Use crontab -e to edit the file! How to change the default editor from vi to nano see The crond service must be running. To determine if the service is running, use the command /sbin/service crond status To restart the srvice: service crond restart (this will load modifications) Each line in the /etc/crontab file represents a task and has the format: minute hour day month dayofweek command Example: 42 4 1 * * root run-parts /etc/cron.monthly minute - any integer from 0 to 59 hour - any integer from 0 to 23 day - any integer from 1 to 31 (must be a valid day if a month is specified) month - any integer from 1 to 12 (or the short name of the month such as jan or feb) dayofweek - any integer from 0 to 7, where 0 or 7 represents Sunday (or the short name of the week such as sun or mon) command - the command to execute (the command can either be a command such as ls /proc >> /tmp/proc or the command to execute a custom script) If a cron task needs to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d directory. All files in this directory use the same syntax as /etc/crontab. Refer to following example for examples. # record the memory usage of the system every monday # at 3:30AM in the file /tmp/meminfo 30 3 * * mon cat /proc/meminfo >> /tmp/meminfo # run custom script the first day of every month at 4:10AM 10 4 1 * * /root/scripts/backup.sh For any of the above values, an asterisk (*) can be used to specify all valid values. For example, an asterisk for the month value means execute the command every month within the constraints of the other values. A hyphen (-) between integers specifies a range of integers. For example, 1-4 means the integers 1, 2, 3, and 4. A list of values separated by commas (,) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers. The forward slash (/) can be used to specify step values. The value of an integer can be skipped within a range by following the range with / . For example, 0-59/2 can be used to define every other minute in the minute field. Step values can also be used with an asterisk. For instance, the value */3 can be used in the month field to run the task every third month. Any lines that begin with a hash mark (#) are comments and are not processed. As shown in the /etc/crontab file, it uses the run-parts script to execute the scripts in the /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly directories on an hourly, daily, weekly, or monthly basis respectively. The files in these directories should be shell scripts. Users other than root can configure cron tasks by using the crontab utility. All user-defined crontabs are stored in the /var/spool/cron directory and are executed using the usernames of the users that created them. To create a crontab as a user, login as that user and type the command crontab -e to edit the user's crontab using the editor specified by the VISUAL or EDITOR environment variable. The file uses the same format as /etc/crontab. When the changes to the crontab are saved, the crontab is stored according to username and written to the file /var/spool/cron/username. The cron daemon checks the /etc/crontab file, the /etc/cron.d/ directory, and the /var/spool/cron directory every minute for any changes. If any changes are found, they are loaded into memory. Thus, the daemon does not need to be restarted if a crontab file is changed. dd With this 'disk dump' command you can create ISO images and floppy images. You can also use it to create imagefiles of partitions and whole disks. Below are some example commands: dd if=/dev/cdrom of=/local/suse90pro-dvd1.iso bs=2048 dd if=/dev/cdrom of=/local/w2003srv.iso bs=2048 The above two examples create an ISO image of a CD/DVD. You can safely ignore the error message usually shown at the end of the media. dd if=/dev/fd0 of=/local/bootfloppy1.img bs=1440k This command creates a floppy image quickly. You can also use the freeware Emt4win utility for Windows download to create floppy images dd if=/dev/fd0 of=/local/bootfloppy2.img bs=512 This might be a bit slower version of the above example. This tool can be used to create an additional swap file. For example, if we did not allocate a big enough swap partition for the service console during ESX installation, we can create one now in a file of 64MB. dd if=/dev/zero of=/swapfile bs=1M count=64 If we did add a swap file, we would need to make sure it is started when ESX starts. Therefore, an entry in /etc/fstab would be needed as this file describes the local and remote file systems to mount at boot. The total amount of service console swap space is the sum of the swap partition and any swap files that are active. See also: mkswap, swapon, swapoff df -h Print disk partitions (with human readable switch) Filesystem /dev/sda2 /dev/sda1 /dev/sda5 none /dev/sda6 /dev/sda8 Size 4.3G 45M 2.7G 93M 1007M 125G Used 644M 12M 33M 0 113M 33M Avail 3.4G 31M 2.5G 93M 843M 118G Use% 16% 28% 2% 0% 12% 1% Mounted on / /boot /home /dev/shm /var /vmimages du Display usage in kilobytes for contents of the current directory or for a specified file or directory. du /bin Show how much disk space is used by the /bin directory. fdisk Command line disk partitioning program in Linux. It is powerful and has a very simple user interface. Please note, that ext2, and ext3 both use the same partition ID. fdisk /dev/sdb On command line, starts fdisk against second available SCSI disk. "sda" is the first SCSI disk, "sdc" is the third SCSI disk etc. VMware ESX Server is installed on /dev/sda, and the external storage is /dev/sdb, and maybe some others too. p Fdisk subcommand, prints the current partition table on current disk. d Fdisk subcommand, deletes an existing partition. Enter the partition number to delete. It is recommended to printout the current partition table before deleting anything. n Fdisk subcommand, creates a new partition. Select partition type (primary, extended, or logical). Almost always you should use the default starting cylinder. For size, enter "+NNNNNm", where NNNNN is the size in megabytes. t Fdisk subcommand, change partition type (id). By default fdisk creates ext2/esx3 type partitions. We might also want sometime to use id "fb", the vmfs type, or some other type. w Fdisk subcommand, writes the current partition table to disk. If you don't get any errors, you don't have to reboot. If you get errors at this point, the new partition table is used only after next system boot. find The find utility is used much in the same way as many Windows people used the DIR command. If you know roughly what files you are looking for, then this is the tool. The ls tool simply lists, whereas the find tool will find according to one or more criteria, a common one being find files modified in the last day using the –mtime switch as shown in the table. –mount -size -mtime -n -mmin -n -ls -name find find find find find find find find find findnic used to ensure it doesn't traverse to remote file systems obvious modified in the last n*24 modified in the last n minutes use output format as if ls were used name the file you are looking for (you just don’t know where it is!) files modified in last 30 minutes files modified in last 24 hours files in excess of 10,000 bytes files on non-remote file system file called hosts do ls on the files found find files with exactly rw-rw-rwfind files with at least rw-rw-rw find files owned by ali –mmin -30 –mtime -1 –size +10000 –mount –size +10000 -ls –name “hosts” -ls -exec ls -al {} \; -perm 666 -perm +666 -user ali The findnic command lets you send network traffic from a specified network adapter so you can observe the LEDs on the adapters and see which physical adapter is associated with that device name. The format of the command is findnic -f Do a flood ping. -i Send pings at specified interval. Example: findnic -f vmnic1 10.2.0.5 10.2.0.4 findnic ?i 3 vmnic1 10.0.0.1 192.168.1.10 The above command will send ICMP echo requests to 192.168.1.10 every 3 seconds. The NIC allocated to the VMKernel does not have an IP address. We need to give an IP address temporary to this NIC, it is specified as the first IP parameter. The second IP is the ICMP destination grep Search for a string from standard input or from a file. This is a powerful command. ls /home -Rla | grep StringToSerach history | tail View Last 10 commands History normally list your past commands, used with tail it will filter to show only the last 10 Display the contents of a specified file one screen at a time. Use the arrow keys to move up and down through the less file. less myfile Display the contents of the file myfile. ll ls Same as ls ?al LiSt files in a directory. -R makes it recursive, and -l shows more information on each item. ls -lh Long format human readable ls -a (List files in a directory including hidden, also known as dot files due to their prefix files.) ls -dl */ (List directories in long format (does not display files). Could add as a shell alias, say lsd.)q ls -clt List lsmode shows information about all loaded modules Lists drivers loaded for the service console linux. Remember this command differs from the vmkload_mod utility which shows the modules loaded for the VMkernel. Module Size Used by Tainted: PF vmnixmod 177056 121 e1000 68456 0 (unused) usb-uhci 21220 0 (unused) usbcore 50112 1 [usb-uhci] megaraid2 32928 6 The same information can be found by cat /proc/modules lspci List PCI devices H1 uses direct HW access -n shows PCI vendor and device codes -t Print tree of PCI Devices -tv for verbose tree -v verbose mode -vv very verbose mode -M never use.It might crash ESX Server Also check the file /proc/ man Displays the manual page for a specified command. Press the spacebar to go to the next screen of text. Press q to exit from the display when you are finished. man cat Display the manual page for the command cat. Exit wit q mkdir Makes a directory. mkdir /data Creates directory /data for the VM configs. Displays the option of a loaded module. modinfo e1000 Will produce a list of possible setting on the Network adapter as flow control With vmkload_mod -l you can list all loaded modinfo mount|umount These commands manually mount/umount CDs, floppies, local partitions, and remote directories to a selected local directory. The local (empty) directory must exist before the mount can succeed. Example mound command would be "mount /dev/sdb5 /data". Permanent mounting is done by editing the /etc/fstab file. mount Shows all the active mounts. mount -a Remounts everything specified in /etc/fstab file. This is probably the very mount command you will be entering. mount /dev/cdrom This command does the default mounting of a CD to the default mountpoint. In Service Console the CD is mounted to /mnt/cdrom directory. mount /mnt/floppy Mounts a normal 1440KB floppy (/dev/fd0) to the specified directory. mount -t iso9660 -o loop /local/w2005srv.iso /mnt/isocd Mount a CD/DVD ISO image file to the specified directory. This is very useful for testing and other purposes. The mountpoint directory must exist (mkdir /mnt/isocd) before mounting. umount /mnt/cdrom Unmount anything mounted to the specified mountpoint. If nothing is mounted, the command does nothing. Mount an ISO at the Service Console: mkdir /mnt/isocd mount -o loop -t iso9660 -r /vmimges/esx2.1.iso /mnt/isocd Re-mount all VMFS partition -t sets the type of file system in this case VMFS. Last two are the volume label and the mount point mount ?t vmfs vmfs /vmfs more Display the contents of a specified file one screen at a time. Use the spacebar to move forward through the file a screen at a time; use the Enter key to move forward through the file one line at a time. more myfile Display the contents of the file myfile more | less These commands are almost the same, and usually act in a pipe. They are used for file pagination to terminal. Below are some example commands: zcat /var/log/vmksummary.1.gz | less more /etc/passwd mv nano Moves and/or renames files and/or directories. Edit a file with a bit easier UI that vi. nano -w /etc/fstab This is probably the very first file editing command you want/need. "-w" turns word-wrapping off, so you can more easily edit longer lines than about 74 characters. nano /etc/inittab nano /etc/bashrc Shows currently active network connections netstat passwd Changes the password for the userid entered as a parameter for the command. Only root can change the password for other users. They can only change their own password with command "passwd". Userids are disabled by default. They are activated by setting a password for them. An example command for root to set a password is the following command: passwd johndoe pidof Finds the PID of a named process. pidof vmware-ccagent ps -ef Show running processes in the service console. ps -ef | grep MyVMName.vmx (finds the process of a runing VM) ps ?A ps ?eaf ps ?eaf |grep vmware-serverd ps ?efw The -f switch is useful as the ?w? indicates wide format, so we can see the full directory path to the vmx file. Another good option is the H option to show the process hierarchy in a similar way to pstree. ps -eH which might keep Solaris people happy as we don't have the ptree utility in Linux pwd reboot route Show the path to the present working directory. Prints the manual page for a command or a configuration file entered as a parameter to this command. Modify or print routingtable route Prints routing table route del ?net default Deletes the default gateway route add ?net default gw 10.20.0.1 Adds a new default gateway rm This is the equivalent of the MS-DOS or Windows command DEL. In other words, this tool deletes files. # rm testfile rm: remove `testfile'? y If you need to remove all the files in a directory then we could use recursion with the -r switch # rm -r /olddata/ Be careful if using wildcards like * with this tool. rpm Red Hat Package Manager (automating software binaries and remembers what files are needed so the software will run properly RPM tracks dependencies and will inform you if additional packages are needed. There is a database of packages and what files they use. If you do an uninstall it will be checked if other packages will also use this files. If you try to uninstall a package that other packages are still dependent upon, RPM informs you about it and refuses to do the uninstall. Single files can not be retrieved, you can only install the whole package or nothing. Install without output: rpm -i packagename or rpm --install packagename Install with verbose output: rpm -ivh packagename Update a package: rpm -U packagename or rpm --update packagename Get a list of all installed packages: rpm -qa Get the version of an installed package: rpm -q package Find out to whiche package a file belonges: rpm -qf Filename Display information about a package: rpm -qi packagename Show the files that will be installed: rpm -qpl packagename To initialize the RPM Database: Careful do only initialize the database if it wasn't initialized before!! rpm --initdb Of course the database doesn't know anything about prior installed packages and in this cases you can install some packages without checking the dependency (for already installed packages. scp scp secure copy Copies files between linux hosts -r -v Recursively copy entire directories. Verbose mode. Setup SSH Key authentication between linux (ESX) servers will enable copy without Password request instructions scp Fikename remoteserver-name:/remoted-destinationdirectory scp /vmimages/w2kadvsrv-sp4.iso root@esxinstructor2.education.vmw:/vmimages/ showmount showmount lists all the clients that have remotely mounted a filesystem from host. -d list directories that have been remotely mounted by clients -a print all remote mounts in the format hostname:directory where hostname is the name of the client and directory is the root of the filesystem that has been mounted -e print the list of exported filesystems service RedHat-made tool for daemon (service) starting/stopping/restarting/status querying. Syntax is "service daemon name [start|stop|restart|status]". Alternate to this command, which works with all Linuces is to call the script directly, like /etc/init.d/httpd.vmware restart, /etc/init.d/xinetd restart, or /etc/init.d/sshd restart. service --status-all This lists all the service daemons and their status. We can find running services by looking for the running status service --status-all |grep running would produce an output similar to the following: crond (pid 1423) is running httpd (pid 1486 1482 1479) is running syslogd (pid 1136) is running sshd (pid 1208) is running To avoid unnecessarily rebooting an ESX server after making certain configuration changes, we can frequently just restart the appropriate daemon. For example we could restart the Apache web server for the MUI with the command: service httpd.vmware restart and we can also check a named service running status with service httpd.vmware status Great way to do orderly restart of vmnix network configuration. service network restart su Switch user. By default, this allows you to log in as the root user if you know the root user's password. You can also use the command to log in as any other user if you know the appropriate user name and password. Enter the command, then enter the password when prompted. su User2 Log in as User2. su - root apply also the new users (root) environment tail -f Like "head", but start from the end of the file. Practical command to follow what is happening with a log file is command like tail -f /var/log/messages. tail -n shows n lines of a files Tape ARchive, a command which combines many files into one for backup purposes. Below are some example commands: tar -cvjf /local/servcons.tar.bz2 --exclude /proc --exclude /local -exclude /vmfs --exclude /data / Create a bzip2'ed tar backup file the whole Service Console. Smaller, slower backup. tar -cvzf /local/servcons.tar.gz --exclude /proc --exclude /local -exclude /vmfs --exclude /data / Create a gzipped tar backup file the whole Service Console. Faster, bigger backup. tar tar -cf /local/vm-configs.tar /data Create a tar backup file of all files in and under /data directory. tar -xvzf /local/vm007-config.tar.gz Extract gzipped tar backup file to current directory. tar -xvjf /local/vm007-config.tar.bz2 -C /tmp Extract gzipped tar backup file to /tmp directory. find / -type f -iname vm007* | tar -cjvf /local/vm007-backup.tar.bz2 Find all files starting as 'vm007', and create a compressed backup tar file of them top vi Shows the running processes in the service console and lists the top consumers of CPU time. Standard UNIX text editor. Ok, so it's not that friendly to use, but it's small, surprisingly powerful and gets the job done. So, what commands do you need to know? These are the core commands to get editing. i Changes to insert mode where you can edit the text ESC Exits the current mode, e.g. out of insert mode back to view mode. :wq Write the file and quit the editor :q! Quit the editor without saving changes SHIFT ZZ Quit the editor and save any changes made These commands are just extra if you have the inclination to learn! $ jumps to the end of the opened file dd delete a line - if you precede this with a number e.g. 8dd, then it would delete 8 lines %s/old/new/g substitute any occurrences of the world "old" with the world "new" There are some great web sites which document the features of vi in superb depth, one of them is the staff site at University of Washington which helped me. Their site is at http://staff.washington.edu/rells/R110/ vdf -h Displays free space for all mounted file systems. vdf is an ESX Server-customized version of the df command. Use vdf in place of the df command. vdf works with all the standard df options. The listing also shows the total space, amount of space used and percentage of space used for each file system. vdf -h (with human readable switch) vmware -v whiche Display ESX Version Number Should display information along this kind ?VMware ESX Server 3.0.1 build-32039 shows the path to the executeable #which nano /usr/bin/nano Run process in background by adding at the end of the command & View and edit files View and edit Files cat grep head less View filecontent Concatenate file from start to standard output (terminal screen by default). Usually takes filename as a parameter. cat > file (Enter text at command line and then CTRL-D to write to file.) Search for a string from standard input or from a file. This is a powerful command. Show selected amount of lines from the start of a file. Display the contents of a specified file one screen at a time. Use the arrow keys to move up and down through the file. less myfile Display the contents of the file myfile. Display the contents of a specified file one screen at a time. Use the spacebar to move forward through the file a screen at a time; use the Enter key to move forward through the file one line at a time. more more myfile Display the contents of the file myfile. These commands are almost the same, and usually act in a pipe. They are used for file pagination to terminal. Below are some example commands: more|less zcat /var/log/vmksummary.1.gz | less more /etc/passwd nano tac tail Edit a file with a bit easier UI that vi. nano -w /etc/fstab This is probably the very first file editing command you want/need. "-w" turns word-wrapping off, so you can more easily edit longer lines than about 74 characters. nano /etc/inittab nano /etc/bashrc Like "cat", but starts from the end of the file (or standard input). Like "head", but start from the end of the file. Practical command to follow what is happening with a log file is command like tail -f /var/log/messages. Standard UNIX text editor I ESC :wq (write and quit) :q! vi Commands to view and edit files vmware-c Netbackup agent installation Just change into the sourcedirectory and start the installation with: ./install Installing Netbackup client Software choose OS Level RedHat2.4 (option 2) Netbackup-Agent will be installed in /usr/openv/ After the installationis completed start in the sourcedirectory: ./firewallConf this script will run the commands: esxcfg-firewall esxcfg-firewall esxcfg-firewall esxcfg-firewall esxcfg-firewall -o -o -o -o -o 13782,tcp,in,bpcd 13782,tcp,out,bpcd 13724,tcp,out,vnetd 13720,tcp,in,bprd 13720,tcp,out,bprd Logical Volume Manager (LVM) We tested our SAN Faileover (IBM FAST T DS4800 with remote mirror) . After a rescan of a newly added LUN with an existing VMFS partition, it is usually not recognized without a reboot of the host. Somtimes it is presented to the console and is also writable there. But to the rest of the Infrastructure, it doesn't exist or is readon To resolve this issue you have to follow the following steps: -Stop all VMs that are running on the test/mirror LUN -Stop all I/O to this LUN, including any management agents that may be run Console -Remove the mapping of the LUN as before -changed to role secondary role -log into VI client -select Datastores view in inventory view -select the datastore, right click, select remove to remove the old label as this is associated with the source volume -added the LUN mapping (with the same LUN ID) to the mirrored (now primary) LUN -changed lvm.disallowSnapshotvolumes to 0 -do a rescan esxcfg-rescan vmhba1 -do a rescan esxcfg-rescan vmhba2 -restart the mgmt-vmware service -log into VI client -select Hosts & Clusters view -in the summary tab, you should see the LUN in the list of datastores Conclusion: It is in the current ESX 3.01 release not possible to do an automatic faileover. Even having all the faileover scripts the problem is o still tries to reach the original LUN which will be removed when it fails. also the datastore needs to be removed before adding the s Special attention needs to by payed to the settings: lvm.disallowSnapshotvolumes Be aware if this is set to 0 all snaphot volumes are presented to the host. Even a secondary LUN will be recognized as snapshotvol might even use such a snapshotvolule without knowing it. The best solution to make shure which volumes are recogniced as snaph to 1 and do a rescan. Additional information: VMFS Volume Can Be Erroneously Recognized as a Snapshot VMware KB article I found this on the forum: ESX3 ships with a Logical Volume Manager (LVM) that supports automatic volume resignaturing. If you snapshot or replicate a VMF tell the difference between the primary and its copy, hence allowing you to access the snapshot/replica from the same physical hos the primary. We will change the identity of the copy, so that there are no namespace clashes. This is different from ESX2, where a mount the snapshot on a different ESX server. If you mounted it to the same server as the primary, ESX2 would get confused beca volumes with the same identity. We call this process automatic re-signaturing, because it doesn't require user intervention. Your diskarray should abide by a checkl publish all this in detail later. For now, you can see your replica on the second ESX server. See session material from VMworld: ESX Server 3.0 Tips and Tricks by Mostafa Khalil VMware Support Engineering. EXT2-fs warning: maximal mount count reached Answer from VMware: We have done some research about the "EXT2-fs warning: maximal mount count reached" and in some configurations is normal to have this warning and there is no need to worry about it, because it's only a warning and there is no ext2 file systems in the server that this warning could be applied. You don't have to worry about it.

Shared by: hao nguyen
Other docs by hao nguyen
JK Connector Installation
Views: 265  |  Downloads: 4
io specs
Views: 267  |  Downloads: 6
Introduction to Unix
Views: 429  |  Downloads: 62
Introduction to PCI Express
Views: 165  |  Downloads: 14
Introduction to NUMA on xSeries Servers
Views: 97  |  Downloads: 3
Installation and Configuration of MRTG
Views: 465  |  Downloads: 9
Implementing the SAN10Q-2
Views: 49  |  Downloads: 1
IBM TotalStorage Ultrium LTO tape selection
Views: 109  |  Downloads: 2
Related docs
VMware - Index of
Views: 53  |  Downloads: 0
Vmware
Views: 6  |  Downloads: 0
SPI for VMware Announcement
Views: 2  |  Downloads: 0
VMWare Post2PDF
Views: 12  |  Downloads: 0
VMware Capacity Planner
Views: 287  |  Downloads: 47
VMware Capacity Planner
Views: 87  |  Downloads: 5
networking_in_vmware
Views: 70  |  Downloads: 11
Bestpractices_vmware
Views: 786  |  Downloads: 37
VMware Paravirtualization
Views: 721  |  Downloads: 44
vmware cert
Views: 61  |  Downloads: 2
VMware-Fact-Sheet
Views: 6  |  Downloads: 0
VMware Virtual Infrastructure
Views: 6  |  Downloads: 0