|
B2V Guide to VMware ESX Server 2.x
Last Updated 5th January 2008 by Alistair Sutherland
This guide has been compiled by the consultants & trainers at Taupo Consulting and is based upon their personal experiences with the VMware ESX Server product. The information in this guide is not verified or sanctioned by VMware Inc and we encourage our website visitors to use www.vmware.com/vmtn as their primary source of VMware product information. We are of course delighted if you find our shared experience documented in this guide of use in your environment.
We are experimenting with different layouts of this help guide, currently a standard HTML table with border. If you have any suggestions, additions or corrections we would be more than happy to receive your emails on vmware@b2v.co.uk. Thanks for visiting our site!
The version of
VMware ESX Server included with Virtual Infrastructure 3 has a number of brand new command line commands!
Click HERE for the guide
to the new v3 commands...
|
Boot Process
|
|||||||||||||
| /etc/lilo.conf | |||||||||||||
|
LILO is the boot loader (LILO=LInux LOader) used
for VMware ESX server. If you are new to Linux, then remember that Windows has a boot loader
too, it's called NTLDR. The Linux version used as the service console in ESX Server 2.x is based
upon a modified version of Red Hat Linux 7.2.
The lilo.conf file is the configuration text file that defines how the Linux OS will boot. If you are familiar with Windows, then this file is similar to BOOT.INI. However, in contrast to the Windows file, the lilo.conf text file is compiled into a binary file, and it is that binary file which is actually used by LILO at boot time. Here is a sample section of a lilo.conf file. You can see the initrd line which specifies the ramdisk image that the boot loader uses to load the Linux service console kernel. The Linux kernel image name is vmnix and many VMware administrators use the term vmnix when referring to the service console. image=/boot/vmlinuz-2.4.9-vmnix2
The pci device mask specified in the append line of lilo.conf is actually an include, not a mask out. The important thing to note is that the append line defines the physical PCI bus hardware that is visible to the service console. ESX manages allocation of PCI devices between service console and VMkernel with the expectation of the boot loader being LILO. You can also view PCI device allocation using the MUI, whilst logged in as root. This is found under Startup Options in the Options tab of the MUI as shown below. Alternatively, you could use the legacy MUI web interface using the URL
http://esxserver/pcidivy The LILO boot loader has a boot prompt as well, displayed rather inconspicuously below the red text menu. It is at this boot prompt that you can supply additional boot parameters. You may wish to restrict LILO from accepting such user-entered boot parameters unless a password is entered. password=<password> If you only enter the password line to the file, then a password would be required to boot the system, if you also have the restricted option then you would only need the password for making boot modifications. In the LILO boot menu, any option that requires a password has a "P" next to the image name and any option with the restricted option has an "R" next to the image name. If it is a concern that the /etc/lilo.conf file contains a password stored in clear text, the file should be secured using permissions that only allow root access, i.e. rwx------. You can implement this with the chmod command and the 600 numeric to represent rw.
|
|||||||||||||
| Boot Order | |||||||||||||
| LILO instructs the BIOS to load the service console kernel, e.g.
/boot/initrd-2.4.9-vmnix2.img This kernel obeys what is stored in the file /etc/inittab.
|
|||||||||||||
| /etc/inittab | |||||||||||||
| This file is read by the Linux init process
during boot and
specifies the run level to be used by the service console. The line in this file that states
the run level will look something like this.
id:3:initdefault: The run level that the service console uses is run level 3, which specifies full multi-user mode. The init process then works through the start up scripts in the appropriate directory. For run level 3, this directory would be /etc/rc.d/rc3.d The file also starts up the virtual terminals on the service console, mingetty tty2 through mingetty tty5. The mingetty process is a manager of virtual terminals for Linux; it is a minimal version of universal getty found in UNIX. It does not support to connections of serial port connected terminals and is therefore "lighter" than getty and performs the majority of most terminal needs. In the past, when UNIX was deployed on large machines and dumb terminals were connected using serial connections, the getty service was used. Nowadays, almost nobody connects to a Linux machine by the serial port, and for that reason it was decided to lighten getty, adopting a "minimum getty" in many distributions of Linux.
|
|||||||||||||
| /etc/rc.d/rc.local | |||||||||||||
| A start up text configuration file most commonly edited when we need to
share the service console's physical NIC (pNIC) with the VMkernel.
This may be required when a server has only 2 physical NICs, but we really want 3, so we can dedicate 1 NIC to VMotion. To do this we add the following lines to the end of the rc.local file.
insmod vmxnet_console devName=vmnic0 /lib/modules/2.4.9-vmnix2/misc/vmxnet_console.o If we do need to do this, then we need to decide which network functions should share a physical NIC (pNIC), for example
So, how you share your pNICs will depend on how much management traffic there is in relation to VM traffic as well as how often VMotion operations are likely to occur. If you need to VLAN tag the service console traffic when using the vmxnet_console module, then you just add the VLAN ID number after the device name in rc.local. For example, to place the service console on VLAN number 105, we would modify the insmod line to read insmod vmxnet_console devName=vmnic0.105
|
|||||||||||||
| /etc/rc.d/rc2.d/ | |||||||||||||
| This directory contains the start-up scripts for run level 2.
|
|||||||||||||
| /etc/rc.d/rc3.d/ | |||||||||||||
| This directory contains the start-up scripts (logical links) for run
level 3. Run level 3 is used most of the time as it is command line full
multi-user mode. The start up scripts all start with the letter "S" and the
following 2 digits indicate the start up order. The "K" scripts in this
directory are shutdown scripts. The S scripts we are interested in for
understanding the ESX server boot process are shown below:
S00vmkstart By looking at the script titles we can guess what some of them do, e.g. S55 starts the secure shell daemon (putty in now!), S56 starts xinetd which amongst other things handles remote console sessions and then S91 starts, which gives us an Apache web server, known to us as simply as the MUI. If you would like to add your own scripts, you can place them anywhere in this start-up order. For example, if you wanted a script to start after xinetd but before the MUI, you could label it something like "S60custom". A neat trick if you are looking to temporarily disable a start up script is to rename the file from capital "S" to lowercase "s".
|
|||||||||||||
| chkconfig --list | |||||||||||||
| This service console tool displays a table showing
which daemons are enabled for the run levels for the Linux service console. The
following is a snip output of the chkconfig --list command ntpd 0:off 1:off 2:on 3:on 4:on 5:off 6:off
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 If we just want to turn on a daemon for the current run level we can just type the name of the service we want to enable/disable with on or off as a parameter. So to turn on nfs daemon for the current run level (whatever that may be) you would type: chkconfig nfs on If you are not sure what runlevel you are currently in, just use the command runlevel and the current runlevel will be displayed.
|
|||||||||||||
| 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
service httpd.vmware restart and we can also check a named service running status with service httpd.vmware status |
|||||||||||||
| S12syslogd | |||||||||||||
| The centralised logging
system. When ESX is running, both the service console and VMkernel log messages
through it. The /etc/rc3.d/S12syslogd file is actually a logical link to the executable file in /etc/rc.d/init.d/syslog
|
|||||||||||||
| logger | |||||||||||||
| This is a great tool for creating manual entries in the log
file. logger -i -t username "This test message will appear in the service console log file!" So now we could examine the last few lines of the service console log file to see our new entry: tail /var/log/messages If you were setting up logging from the service console of one ESX server to a centralised log server, then this would be a great way of testing that the centralised logging was working as expected.
|
|||||||||||||
| /etc/ssh/ | |||||||||||||
| This directory contains the "Secure Shell" configuration
files. The service console has both a secure shell client and a secure
shell server (daemon). A quick way to restart the SSH daemon is to enter: # /etc/init.d/sshd restart It is important to use the full path to the ssh daemon to do this. An easier way to do this is by using the service command service sshd restart The configuration of the SSH server daemon is stored in the text file /etc/ssh/sshd_config. 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 If you do edit the file, make sure you restart the service for the changes to
take effect. |
|||||||||||||
| ssh | |||||||||||||
| This is the secure shell client.
We can use it to gain a command line session with a remote host, typically the service console of another ESX Server. In the following example, we are logged on to the service console of ESX server "esx01" and we are opening a command line session with the service console of ESX server "esx02". [root@esx01 root]# ssh esx02 Once you have established an ssh session with another host, the known_hosts file on your server is populated.
|
|||||||||||||
| ~/.ssh/known_hosts | |||||||||||||
| The text file ~/.ssh/known_hosts stores the RSA keys for known
hosts. This file is in the hidden subdirectory .ssh, found in every users' home
directory. Note this file is maintained on a
per-user basis. The ~ (tilda) character in the path above denotes a variable
corresponding to the currently logged on users' home directory.
The .ssh subdirectory is not created until you make an outbound ssh or scp connection to another host. If you rebuild one of your ESX hosts, when you try to reconnect to it over ssh you may be prevented from connecting, if the known_hosts file has cached the old key. In the following command, we examine the contents of the known_hosts file (we've truncated the length of the key here!) [root@esx1 root]# cat .ssh/known_hosts
|
|||||||||||||
| ssh-keygen | |||||||||||||
| Generate a public & private key set for the ESX Server. The -t switch specifies type ssh-keygen -t dsa
|
|||||||||||||
| /etc/xinetd.conf | |||||||||||||
| This is the configuration file for xinetd, the eXtended
InterNET services daemon. Originally the inetd daemon helped in controlling network connections to a computer. When a request arrives at a TCP/UDP port that is managed by inetd, the request is forwarded to a program called tcpd (/usr/sbin/tcpd). Then tcpd decides, in accordance with the rules contained in the hosts.{allow, deny} files whether or not to grant the request. If the request is allowed, then the the corresponding server process (e.g. ftp) can be started. This mechanism is also referred to as tcp_wrapper. xinetd provides access control capabilities similar to the ones provided by tcp_wrapper. The daemon itself is stored in /usr/sbin/xinetd This launches the daemons that are bound to it on demand.
|
|||||||||||||
| vmware-authd | |||||||||||||
| This is the authentication daemon. This daemon
authenticates users of the management interface (MUI) and remote consoles using
the username/password database defined in /etc/passwd. This service binds via
the xinetd daemon and so the configuration file that specifies the listening
port is /etc/xinetd.d/vmware-authd This text file contains the settings for the VMware remote access authentication daemon. This file specifies the TCP:902 port used by remote console. If we wanted to add Kerberos off-box authentication for MUI access, then its in the pluggable authentication module configuration file that corresponds to this daemon that we would make a change. This file is found at /etc/pam.d/vmware-authd We would need to change the current "auth required" to "auth sufficient" and add a last line of "auth required" using the Kerberos authentication module. Modification may be required to the /etc/krb5.conf, /var/kerberos/krb5kdc/kdc.conf for server locations and /etc/hosts to resolve these server IP addresses.
|
|||||||||||||
| S11vmware | |||||||||||||
| This is a file in the
/etc/rc3.d/ directory and performs the following actions:
vmnix driver Loaded by modprobe
vmnixmod.o
|
|||||||||||||
| vmware-serverd | |||||||||||||
| This daemon runs on demand in
the service console to provide information to any VMware service that needs it.
This performs actions in the service console on behalf of the VMware Remote
Console and the web based MUI. It is started at boot time to do any VM
autostarts. This process is replaced with vmware-ccagent if VirtualCenter is
installed.
|
|||||||||||||
| vmware-ccagent | |||||||||||||
| This daemon runs as the replacement for
vmware-serverd that is installed when the server is managed by VirtualCenter.
The vmware-ccagent process is automatically installed on an ESX host simply by
adding the host to a VirtualCenter farm, i.e. the process upgrade is transparent
to the VC administrator. If the automatic install of this component fails, it can be installed manually by copying the appropriate RPM package from the VirtualCenter server to the ESX host which is to be VC-managed. Copy the RPM from C:\Program Files\VMware\VirtualCenter\ccagent\ to the ESX host and then from the command line run rpm -Uav VMware-ccagent-esx-2.5.0 The most likely reason you would need to do this manual method is when the VC server is on a separate subnet from the ESX host and there is a firewall in-between. Even if TCP:902 is open between the subnets, some dynamic ports are temporarily required for this vmware-ccagent install.
|
|||||||||||||
| S91httpd.vmware | |||||||||||||
| This script starts the Apache web server which
provides the ESX Server MUI. Configuration is stored in
/usr/lib/vmware-mui/apache/conf/httpd.conf This process communicates with vmware-serverd for backend data. Remember a refresh in the browser is only a refresh to Apache, to get new data, click on the refresh button to get new kernel data. Remember if the httpd.vmware service starts and then stops immediately, check your service console disk space. The S91httpd.vmware
entry in /etc/rc3.d is a logical
link to /etc/rc.d/init.d/httpd.vmware The HTML files for the MUI can be
found in the following path
|
|||||||||||||
| snmpd | |||||||||||||
| This is the Master SNMP daemon in the service console. SNMP services in ESX
Server are
comprised of the Master SNMP Agent and the VMware SNMP SubAgent. If you are like
me and don't use SNMP everyday, then a great resource for understanding
this simple, but powerful protocol can be found at
http://www.dpstele.com/layers/l2/snmp_l2_tut_part1.html.
The root of the VMware MIB is enterprises 6876 The Master SNMP agent (snmpd) can be replaced with the HP Insight Agent or Dell OpenManage as required. The MIBs are stored on an ESX Server in the directory /usr/lib/vmware/snmp/mibs
|
|||||||||||||
| vmware-snmpd | |||||||||||||
| This is the VMware SNMP SubAgent daemon.
|
|||||||||||||
| snmpsetup.sh | |||||||||||||
| This script sets up a new snmpd.conf file
which allows you to see VMware ESX Server MIB items. The normal use of
this script would be to run: # snmpsetup.sh default This would produce an output similar to the following: Stopping agents. chkconfig snmpd on Then enable the VMware SNMP SubAgent for required run-levels with chkconfig vmware-snmpd on Then we can start both SNMP daemons with # service snmpd start Also note, that if you are configuring snmp entirely from the command line, then you will also need to update the file /etc/vmware/config to include the text serverd.snmpdconf.subagentenabled = "TRUE"
|
|||||||||||||
| /etc/snmp/snmp.conf | |||||||||||||
|
This is the configuration file for the Master SNMP Agent. The following is the default contents of this file after ESX has been installed. syscontact root@localhost (edit /etc/snmp/snmpd.conf)
|
|||||||||||||
| vmware-snmptrap | |||||||||||||
| snmpwalk | |||||||||||||
| Used to walkthrough SNMP mibs. -M – use MIBSDIR -m all use
mibs list instead of default mibs list.
|
|||||||||||||
| SNMP Receiver | |||||||||||||
| A utility to display SNMP
traps. MIBs can be loaded into this.
|
|||||||||||||
| lsmod | |||||||||||||
| Lists the device driver modules loaded for the service console
Linux.
So we will see the service console dedicated network card module, local SCSI
adapter module and even USB modules. Here is the output from lsmod Module
Size Used by Tainted: PF If a module has a tainted value of 1, this denotes the driver is not covered under the GNU license. The same information that lsmod produces can also be found by inspecting the file /proc/modules. We would do this with a tool such as cat. For example: # cat /proc/modules There is a different command which lists the driver modules that the VMkernel is using which is called vmkload_mod and can also be found in this guide.
|
|||||||||||||
| Starting & Stopping ESX Server
|
|||||||||||||
| init 0 | |||||||||||||
| Instructing a halt.
|
|||||||||||||
| init 1 | |||||||||||||
| Instructing run level 1
|
|||||||||||||
| esx 1 | |||||||||||||
| If this is entered at the LILO
boot prompt we can get a root shell. We are instructing the vmnix kernel to
execute at run level 1 (single user mode).
|
|||||||||||||
| esx 3 | |||||||||||||
| Again at the LILO boot prompt, this time, we are
instructing the vmnix kernel to execute at run level 3 (the default). If we
suspected the run level was wrong we can use this to get back up and running
without having to revert to booting Linux on its own.
|
|||||||||||||
| linux rescue | |||||||||||||
| Used when you boot the ESX
server with a Red Hat Linux CD.
|
|||||||||||||
| chroot | |||||||||||||
| Change root directory to new directory specified
as a parameter.
|
|||||||||||||
| shutdown | |||||||||||||
| Brings down the system in an orderly way. This will
execute the kill scripts for the current run level, which should be 3
(full multi-user), i.e. the scripts which start with the letter 'K' in
the directory /etc/rc3.d/ will be
executed in order.
shutdown -h now
Halt after shutdown
|
|||||||||||||
| linux -s | |||||||||||||
| At the LILO boot loader, the default options are
esx
Normal ESX boot If we use the cursor key at the LILO screen to select one of the three default choices, the boot prompt (displayed below the menu) changes to reflect this. This allows us to augment the boot command with an option switch. boot: linux –s In this case, the –s instructs Linux to boot in single user mode. A critical security point here is that in single user mode, Linux automatically logs on as root! Once in single user mode if we wish to continue into multi-user mode then we type either exit or CTRL-D. To restrict access to single user mode, check the "restricted" parameter in the configuration file /etc/lilo.conf.
|
|||||||||||||
| RPM Utilities
|
|||||||||||||
| rpm | |||||||||||||
| As ESX service console is based on modified Red
Hat Linux, we can use the RPM package installation method. The following command
switch (-qa) lists the rpms installed in the service console.
# rpm -qa If we are only interested in the VMware rpms, then we can just pipe the output of rpm -qa command into the grep search tool. rpm -qa |grep VMware which should yield an output something like VMware-mui-2.5.0-11548 If we then want to find out more information on an individual RPM package, we can use the rpm -qi option to query a package which reports the file version, vendor, license and description.
# rpm -qi VMware-ccagent-esx-2.5.0-11343 If we then want to know what files are included in the rpm package, we can use query with the list option to see the files inside. For example, to see the files # rpm -ql VMware-perftools-2.5.0-11548
|
|||||||||||||
| rpm2cpio | |||||||||||||
| If you are wanting to extract a single file from a RPM
package but you don't want to install the RPM, then this is the tool for
you. Probably best if you copy the RPM to a temp directory so when you
extract the RPM you can then navigate the directory structure created in
that temp directory to find the file or files you need. # rpm2cpio VMware-perftools-2.5.0-11548.rpm | cpio -idmv i = Restore archive
|
|||||||||||||
| Networking Files &
Utilities
|
|||||||||||||
| ifup | |||||||||||||
| Used to bring up a network interface. For example, to
bring the eth0 interface up, we would enter: # ifup eth0
|
|||||||||||||
| ifdown | |||||||||||||
| Used to take a network interface down. For example # ifdown eth0 would take Ethernet interface “eth0” down. If we wish to take the interface down and then up again, we can separate these two commands with a semicolon to run the commands consecutively.
|
|||||||||||||
| ifconfig | |||||||||||||
| Prints a list of the network interfaces. If you are used
to using ipconfig in Windows operating systems, this is a very similar
tool, as such it is a quick
way of finding out the IP address and MAC address of the service console NIC.
The tool can not only report on the interfaces by can perform some
actions as well, such as taking the interface on or offline. ifconfig eth0
ifconfig
eth0 up
|
|||||||||||||
| mii-tool | |||||||||||||
|
Media Independent Interface tool. This tool can be used to force the service console network to a particular speed or duplex. # mii-tool -F Doesn’t work correctly with some network cards, including Intel 1000 Pro copper NICs.
|
|||||||||||||
| service network restart | |||||||||||||
| Great way to do orderly restart of vmnix network
configuration. Another way would be to enter the following:
ifdown eth0; ifup eth0 Or instead of using the word service, some use /etc/init.d/network restart
|
|||||||||||||
| /etc/nsswitch.conf | |||||||||||||
| This is the name service switch configuration file. If
you need to modify the order of how names in the service console are
resolved, this is the place to make the change. You can view and edit
this conf file as usual.
There will be a number of lines to this file, but the one you are likely to be interested in will start "hosts:" as shown: hosts: files nisplus dns In the above example, the name service will use the /etc/hosts file, then NIS+ and then the DNS name server specified in the /etc/resolv.conf file.
|
|||||||||||||
| /etc/hosts | |||||||||||||
| This is the host name resolution lookup file, just like
Windows has in the %windir%\system32\drivers\etc directory. The ESX server MUST have an entry for itself in its own
hosts file. This file should be correctly populated during the
installation of ESX Server. Here is a sample
hosts file from the service console #
Do not remove the following line, or various programs Notice that each line has a 3rd column which specifies an alias.
|
|||||||||||||
| hostname | |||||||||||||
| This utility displays the service console hostname.
There are some useful switches to this command hostname -i displays the IP address and hostname -s displays the short hostname, i.e. without domain name
|
|||||||||||||
| dnsdomainname | |||||||||||||
| This utility will report the domain name if the following
are set /etc/resolv.conf
- search domain.com, nameserver=w.x.y.z This tool does not appear to let you set the DNS domain name.
|
|||||||||||||
| /etc/resolv.conf | |||||||||||||
| The text configuration file contains the DNS name server
settings, i.e. the IP addresses of the DNS servers that the service
console should use for host name resolution. This file does not need to
be present if you are not using DNS. search
taupoconsulting.net
|
|||||||||||||
| /etc/sysconfig/network | |||||||||||||
|
This text configuration file contains the service console hostname and default gateway IP address.
NETWORKING=yes
|
|||||||||||||
| /etc/sysconfig/network-scripts/ifcfg-eth0 | |||||||||||||
| The ifcfg-eth0 configuration
file contains the IP address, subnet mask and device name for the service consoles
network connection. Specifically, the
file contains the IP configuration for interface eth0, typically the only
network interface the service console has.
DEVICE=eth0 |
|||||||||||||
| /etc/sysconfig/network-scripts/network-functions | |||||||||||||
| This file is found in Red Hat Linux VMs and may
require editing if there is a problem obtaining a DHCP address in the guest OS.
A VMware knowledge base article exists (977) which describes this fully, but the
following text may require editing in this configuration file:
check_link_down () { Note this update only relates to Linux Guest operating systems inside a VM, this is not a setting required for the ifcfg-eth0 file in the service console. |
|||||||||||||
| route | |||||||||||||
| This command modifies or prints the routing table in the
service console.
route
Prints routing table |
|||||||||||||
| netconfig | |||||||||||||
| This is the Red Hat Linux network configuration setup
program. If you need to reconfigure the service console network settings, e.g.
change IP address or default gateway etc then this is a great quick way
to achieve that without resorting to directly editing the configuration
files where these settings are stored. Simply enter
netconfig without any parameters.
/etc/sysconfig/network-scripts/ifcfg-eth0
|
|||||||||||||
| /etc/issue | |||||||||||||
| File which shows ESX and vmnix version
VMware ESX Server 2.1.2
|
|||||||||||||
| uname | |||||||||||||
| If you specify this command with the -a switch, an output
similar to the following is seen: Linux esx1.taupoconsulting.net 2.4.9-vmnix2 #1 Fri Aug 6 04:38:44 PDT 2004 i686
|
|||||||||||||
| /proc/net/NICfamily/eth0.info | |||||||||||||
| A text file that can be
checked to see what the service console NIC is doing. The speed of the console
NIC specified in the file modules.conf can be confirmed by this file.
|
|||||||||||||
| netstat | |||||||||||||
|
This command displays the currently active network connections. netstat --inet -n -p -e
|
|||||||||||||
| User Administration
|
|||||||||||||
| id | |||||||||||||
| Displays the user ID (UID) for the currently logged on user,
or if the command is supplied with a parameter, can be used to display the UID of a named user. id robin would reveal something like: uid=508(robin) gid=510(robin) groups=510(robin),506(techsupport) This output tells us that the user robin has a UID of 508, a primary group membership of robin and secondary group membership of techsupport.
|
|||||||||||||
| alias | |||||||||||||
| Great for adding your own command line
shortcut commands. For example, HP-UX administrators may be very used to
just typing "lsf" to list the contents of a directory. Now this is just "ls
-F" but we want the short way of typing it alias lsf='ls -F' The above command alias will not however persist to another login session. To have that alias available to you on next login, you would need to add this text to your .bashrc file in your home directory. To make the alias available to all users on the system, you could add the alias definition to the file /etc/bashrc, which is referenced by the users' /home/<user>/.bashrc file, like an include. If you just type alias without parameters, you will see a list of the aliases you have defined.
|
|||||||||||||
| passwd | |||||||||||||
| Used to change the password of the currently logged on user
(use the command with no parameters) or for changing the password of a named
user account (supply the user name as a parameter). passwd <user> Remember that passwords are not stored in the /etc/passwd file, but in the file /etc/shadow If you are ever needing to
reset an unknown root account password, then it is this utility you
would run after booting into Linux single user mode. |
|||||||||||||
| adduser | |||||||||||||
| This is just a symbolic link (shortcut!) to the
useradd utility.
|
|||||||||||||
| useradd | |||||||||||||
| This command adds a user and so updates the
/etc/passwd file. So the following
command:
useradd sally would add a user called sally. We could equally have created a service console user by using "Users and Groups" in the Options tab of the MUI. We can set more than the basic properties of a user account with some additional switches. The following command useradd robin -G techsupport -s /bin/bash -d /home/robin would add a user called robin who is a member of the techsupportusers group and has a home directory /home/robin and will receive the Linux bash shell at login. The service console is a modified version of Red Hat Linux (RHL), and by default in RHL, when a user account is added, a group is created of exactly the same name and has only the user account as a member. This feature is called User Private Groups (UPG) and is discussed in more detail on the RedHat documentation website found here. So, now that we know about UPGs, looking again at the command above, the command adds a user called robin whose primary group (-g) is called robin and other group (-G) membership is techsupport We can add additional parameters to the useradd command to more fully specify the account. useradd alistair –g Finance –s /bin/false In the above example the users’ primary group is Finance and the shell is specified. In this case the shell is /bin/false which is a bogus shell which would prevent interactive logon by this user. By default in the service console, the shell assigned to users is the BASH shell - specified as /bin/bash (BASH stands for Bourne-Again SHell). It appears the only other Linux shell that is shipped with the service console is csh (the C shell).
|
|||||||||||||
| groupadd | |||||||||||||
| Adds a group to /etc/group
groupadd esxadmins In the above example, a new group called esxadmins is created and therefore a new line appears in /etc/group.
|
|||||||||||||
| gpasswd | |||||||||||||
| The best tool for adding users to groups, which
updates the /etc/group configuration file.
The following command adds the user greg to the
esxusers secondary group.
gpasswd –a greg esxusers Group removal is simple with the –d switch: gpasswd –d tony esxusers
|
|||||||||||||
| usermod | |||||||||||||
| This command is used to modify a user.
Be very careful with this command if you intend to use it to modify a users' group membership. When used with –G to set the users group membership, it is not adding the user to a group but is actually setting the list of secondary groups a user belongs to. Therefore in the following example if bill had secondary group list of esxusers and sqladmins, then after entering: usermod –G techsupport bill then bill would only have a secondary group of techsupport and nothing else! We would have overwritten the entry in the /etc/group file that listed bill as a member of esxusers and sqladmins. This is why the command gpasswd is so much clearer. It is good to use the id command to check what groups a user is a member of, before and after the user modification operation to ensure you have got it right.
|
|||||||||||||
| groupmod | |||||||||||||
|
This command is used to modify a group, typically to rename it. groupmod -n newgroupname oldgroupname
|
|||||||||||||
| su | |||||||||||||
| This command is the switch user utility.
When it used without parameters, we are specifying to switch to the user root. However, we can use the su command to switch shell to any user account. In the first example, we are logged in as the user kevin and we are switching to user ali. [kevin@esx1host kevin]$ su ali In this second example, we are switching from being logged on as a user called sara to being logged on as root. Notice to switch to root, we don't need to specify a username. [sara@esx1host sara]$ su - If we restrict the built-in user account root from logging in over the SSH protocol, then we are forcing remote users to authenticate as themselves and then su to run privileged commands if need be, thus leaving a decent audit trail. The downside being that those users would still know the root account password. If you would like to restrict the use of the su command, then we can limit it to the members of a specific group called wheel. This group is defined in the /etc/group file by default and it's membership can be modified by root. In order to limit su to the wheel group members we need to modify a configuration file called /etc/pam.d/suThere is a single line in this file that needs to be uncommented to limit the use of su. The line is shown below as it appears it that file, all that is required is the removal of the # symbol at the start of the line. #auth required /lib/security/pam_wheel.so use_uid
|
|||||||||||||
| sudo | |||||||||||||
| Allows delegation of
administration in terms of certain commands that normally only a particular user
can execute (usually root). So if the user ali had been given the authority
to run vmkfstools, then sudo would be used like: [ali@esx1 ali]$ sudo vmkfstools The vmkfstools command would then run under the security context of the root user. The superb feature of this tool is that the user ali does not need to know or supply the root password to be able to run the delegated command. Further, we can keep an audit trail of when sudo was invoked.
|
|||||||||||||
| visudo | |||||||||||||
| This is just the vi text
editor, but it automatically opens and locks for exclusive edit, the /etc/sudoers file. The point of
visudo is
to ensure we always edit the right file as the location of the
sudoers file
differs between nix distributions, but this command is constant and will utilise
the right sudoers file for the distribution being used. But a great benefit of using visudo over vi, is that it performs some basic syntax checking for us!
|
|||||||||||||
| /etc/sudoers | |||||||||||||
| The text file that contains the sudo users and the
rules that apply to them. The first "ALL" relates to all machines (useful if
this is a network wide file). Otherwise, this could be the hostname of the one
machine we are trying to run the command on. In the following example we are
allowing the user "alistair" to run the kill command, commands in
/usr/bin and
commands in /usr/sbin/alistair alistair ALL= /bin/kill, /usr/bin/, /usr/sbin/alistair/ The best source I've found so far on detailed use and background of sudo can be found at http://aplawrence.com/Basics/sudo.html |
|||||||||||||
| /etc/group | |||||||||||||
| This file contains a list of the security groups defined
in the service console.
We don't normally directly edit this file, but we use the user
administration
kirsten:x:505:kirsten This may look like a list of users, but it is a list of groups. As the service console (vmnix) is a modified version of Red Hat Linux, the Linux security configuration is the same as Red Hat. One feature of Red Hat not found in all Linux distributions is that of the user private group (UPG). Whenever you create a user, a group of the same name is created also and the user is made a member. The format of the file is: groupname:x:user1,user2 so when we see groups like JohnSmith:x:513 we can assume the 513 is the UID for the user JohnSmith and this is his UPG.
|
|||||||||||||
| /etc/passwd | |||||||||||||
| This file contains a list of users defined on the
server. When we add a user account to ESX server (with
either the MUI or a command line tool such as useradd) we are adding to this
text file.
Here is a sample section of a passwd file: ali:x:500:500:Alistair Sutherland:/home/ali:/bin/bash As shown, the format of the file is username:x:userID:groupID:fullname:homedirectory:shell Normally the group ID will match the user ID. There is a command line tool to edit this file, vipw
|
|||||||||||||
| vipw | |||||||||||||
| Launches vi text editor and opens the
/etc/passwd
file.
|
|||||||||||||
| /etc/shadow | |||||||||||||
| This text file contains the user accounts'
encrypted passwords. ali:$1$tkSdSEQD$x8pXvtDZ3Xta6zza9lKqh.:12733:0:99999:7::: If a user account has been disabled with the usermod command, a "!" will be placed in front of the encrypted password in this file.
|
|||||||||||||
| /etc/skel/ | |||||||||||||
| This is the skeleton directory; new home
directories are populated with copies of the files stored in here.
|
|||||||||||||
| NIS | |||||||||||||
| Network Information Service, formerly known as Yellow Pages. NIS is a network lookup service which consists of databases and processes. It works where a NIS master server stores the source files for the maps such as /etc/passwd A NIS master serves a NIS domain. You can have multiple NIS servers for a domain, but only 1 is the master, other NIS servers host read-only copies, i.e. they are slaves. NIS databases are in DBM format. The NIS master server daemon is ypserv. NIS client machines are those which get their configuration from the NIS Master. A NIS client runs the process ypbind.
|
|||||||||||||
| ypserv | |||||||||||||
| ypbind | |||||||||||||
| The NIS client runs this process.
|
|||||||||||||
| yp-tools | |||||||||||||
| The collection of ypset, ypwhich, ypcat
|
|||||||||||||
| /var/log | |||||||||||||
| This directory stores key log files for both the service
console and the VMkernel.
Of note are the vmkernel, vmkwarning & messages file logs. These logs can be viewed with the more, cat, head and tail command line tools. We can also access these logs via the MUI via the following link in the Options tab.
If you use the sudo tool to run a command under a different security context then the log file /var/log/secure will contain the audit trail for such activity. Check the file /etc/syslog.conf for logging settings. You can use less /var/log/logfile and then use SHIFT-f to enable dynamic update as new data is delivered to that file.
|
|||||||||||||
| /etc/syslog.conf | |||||||||||||
|
This configuration file defines the system logging
settings. It is sometimes useful to add a line to the end of this file local6.* /dev/tty3 to get real-time logging of VMkernel to tty3.
|
|||||||||||||
| lsof | |||||||||||||
| List open files Pipe the results into grep to
check for open ports
lsof |grep IPv4.\*LISTEN
|
|||||||||||||
| pam | |||||||||||||
| Pluggable Authentication Module. This allows ESX
server to use off-box authentication sources, e.g. Active Directory, eDirectory/NDS,
LDAP directories.
|
|||||||||||||
| free | |||||||||||||
| Shows free memory in the service console. The "-m"
switch specifies to display the results in megabytes. If the service
console is low on memory, you can increase the amount of physical RAM it
gets using either the MUI (Options tab, Startup Profile) or the command
line tool vmkpcidivy. Here is the output of running free -m
total used free shared buffers cached Given these results, I would be thinking about either running fewer VMs, disconnecting unused devices from VMs, stopping any unnecessary applications or increasing service console RAM.
|
|||||||||||||
| fdisk | |||||||||||||
This is the standard Linux disk partitioning tool. As an
ESX administrator you shouldn't need to use this for partition creation,
but it's great for viewing the partition table. It gives great
information that augments the output of the vdf
-h command.[root@esx1 root]# fdisk -l Disk /dev/sda: 255 heads, 63 sectors, 17816 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 6 48163+ 83 Linux /dev/sda2 7 235 1839442+ 83 Linux /dev/sda3 236 304 554242+ 82 Linux swap /dev/sda4 305 17816 140665140 f Win95 Ext'd (LBA) /dev/sda5 305 1834 12289693+ 83 Linux /dev/sda6 1835 2063 1839411 83 Linux /dev/sda7 2064 2076 104391 fc Unknown /dev/sda8 2077 17816 126431518+ fb Unknown Looking at the above output of the fdisk command, the last two partitions are for the VMkernel. Partitions of type "fc" correspond to the VMKcore dump partition. Partitions of type "fb" are VMFS volumes. If you wanted to create a new VMFS volume from the service console command, then you could use fdisk to create the custom partition type.
fdisk /dev/sdf
|
|||||||||||||
| makefs | |||||||||||||
| If you are creating a new ext3 partition in the service
console, then you should use fdisk to
create the partition and then use makefs
to create the ext3 file system on the partition; the process of creating
the block groups and inodes. In the following example, we have added a 2nd disk to the service console (appearing as SCSI disk "b" i.e. /dev/sdb). By using fdisk we have created a primary partition. Now, to create the file system we use makefs makefs -t ext3 /dev/sdb1
|
|||||||||||||
| e2label | |||||||||||||
| To label the ext3 file system you have just created, you
can use the e2label command. e2label
|
|||||||||||||
| du | |||||||||||||
| Disk usage. Great for finding out which folders
are using disk space du –h /home/ali/vmware
|
|||||||||||||
| df | |||||||||||||
| Command to list disk partitions with their capacities
and free space statistics. We normally use this command with the -h
switch to indicate human readable.
# df -h
|
|||||||||||||
| vdf | |||||||||||||
| Print disk partitions with knowledge of VMFS
partitions (type FB) with human readable switch.
This is a great tool to run when first diagnosing
an ESX server. The results of this command tell us whether the server was
partitioned correctly and if any partitions are constrained for disk space. When troubleshooting, make this your first command to run. You will be able to review if each partition for the service console and the VMkernel has enough disk space. Just take a quick look down the "Avail" column and if you see a zero there's likely a problem right there, or just look at the USE% column.
|
|||||||||||||
| dd | |||||||||||||
| Disk dump utility common to Linux. This can be used to
copy a file while converting and formatting. This can be a quick and
dirty way of making an ISO CD-ROM image. This could be done in the
service console with dd if=/dev/cdrom of=/vmimages/new.iso bs=32k This tool could also be used to go from ASCII to EBCDIC etc. 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 the file system table /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.
|
|||||||||||||
| mkswap | |||||||||||||
| A command that must be run against a newly created
service console swap file in order to activate it. Think of creating a swap file with
the dd command is like
creating a partition, then mkswap is like formatting that partition. The
swapon
command then enables the swap space when you need it.
|
|||||||||||||
| swapon | |||||||||||||
| Enables swap file for service console.
|
|||||||||||||
| swapoff | |||||||||||||
| Disables swap file for service console.
|
|||||||||||||
| /proc/swaps | |||||||||||||
| 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).
Filename
Type Size Used Priority |
|||||||||||||
| File Commands
|
|||||||||||||
| touch | |||||||||||||
| When used with a non-existent
filename, this tool creates an empty file of name filename.
# touch newfile However, this can be used to touch an existing file and update its last modified or last accessed attributes. This could be scripted if required. Be careful and avoid running touch against any file stored on a VMFS volume, as there appears to be a problem there. Remember that not all Linux tools are modified for VMFS awareness. The VMFS is not an ext3 partition. but the directory /vmfs in the service console provides mount points to the VMkernel-mounted VMFS volumes.
|
|||||||||||||
| cat | |||||||||||||
|
This command is used frequently to view the contents of a text file, exactly as the command type in DOS or Windows command line. So to view a view we could enter # cat /etc/vmware/netmap.conf Technically, this is the tool to concatenate files together. We can also use this tool to create text files quickly at the command line, by entering the text and then using the key sequence CTRL-D to write to file. In the following example, we create a new bare-minimum vmx file at the command line.
# cat > newVM.vmx
|
|||||||||||||
| echo | |||||||||||||
| echo blah > file Writes the text following echo command to file. This could be good for quickly creating files echo modprobe usb-uhci > S92usb Another great use of this technique is to make changes to the ESX server configuration via the /proc hierarchy, e.g. changing the number of shares for a VM echo 2500 > /proc/vmware/vm/nnn/cpu/shares would change the VM CPU shares to 2500. However such a change would only exist for the duration of the world created for that VM. After the VM is powered off this in memory structure is lost. To make such a change persistent, we would need to add the line sched.cpu.shares = "2476" to the VMX file of the virtual machine.
|
|||||||||||||
| head | |||||||||||||
| By default, the head command prints the first 10 lines
of the specified file. We can choose how many lines we want instead of
10 by specifying the –n switch. This is good for looking at the file
/proc/vmware/vmhba:x:x:x/0:0 with the –n 22 switch. Also good for using
with the file command to determine whether a virtual disk is in ESX
format or COW format. head server.dsk | file - The “–“ is crucial to making the above command work. For an ESX virtual disk we would expect to see something like standard input: x86 boot sector.
|
|||||||||||||
| tail | |||||||||||||
| Prints the last 10 lines of the specified file.
Just like the head command, there is a –n switch that can be specified to list
the last n lines of the named file. If
you are using this to view the last few entries in a log file, you can use the
-f switch to "follow" changes as they happen to the file. |
|||||||||||||
| sort | |||||||||||||
| Can alphabetically or numerically sort redirected
command output or files.
sort /etc/vmware/vm-list or to sort a basic score sheet sort –g –k 2 scores.txt |
|||||||||||||
| grep | |||||||||||||
| Group regular expression, used to string search
the files or command outputs. You can use grep –i to indicate search with case
insensitive.
Grep can be used as a command directly e.g. grep alistair /etc/passwd or the output of a command can be piped directly into grep, for example the output of all running processes in the service console could be searched for the string "vmware" ps -eaf |grep vmware
|
|||||||||||||
| cut | |||||||||||||
| This utility is great for stripping out unnecessary data
from a file or command output. For example, if we were viewing the
contents of a file and we wished just to view a particular piece of the
file, we could use something like: # cat /proc/vmware/vm/*/names | cut -f1-5,25- -d" "
|
|||||||||||||
| cmp | |||||||||||||
| This is a file compare utility which is useful for
comparing two files.
|
|||||||||||||
| 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 used to ensure it
doesn't traverse to remote file systems find –mmin -30
files modified in last 30 minutes
|
|||||||||||||
| vi | |||||||||||||
| We can't talk about the command line without talking
about vi. This is the simple but powerful text editor in Linux and UNIX.
People tend to love it or hate it. Either way, it's nearly always there
in any *nix implementation and just by memorising a few commands you can
be up and running with it. If you can use Windows Notepad, you can use
vi! vi filename The first thing that throws you is that to enter text into your file, you need to press "i" for Insert mode. You can then enter your text just as any other text editor. When you are done with text entering, just press the Escape (Esc) key to come out of insert mode. If you are happy with your file, then we need to Write & Quit (wq). To enter commands in this command line editor, rather than having menus, we have a command prompt in the application. To reach the vi command prompt, simply enter ":" - the colon character which will automatically place your cursor at the bottom of the session. Here you can enter the "wq" command to write and quit the editor. That's it! Here is a summary of the vi commands i Changes to insert mode where you can edit the text These commands are just extra if you have the inclination to learn!
/
search - if you entered /failed then the cursor would move to the first
instance of "failed in the text
|
|||||||||||||
| nano | |||||||||||||
| Another text editor, more friendly but you should
use –w to avoid word wrap. |
|||||||||||||
| wc | |||||||||||||
| Word count utility. wc filename
|
|||||||||||||
| setup | |||||||||||||
| Allows changing of NIC, region, firewall, mouse,
keyboard. authconfig |
|||||||||||||
| ls | |||||||||||||
| ls -a List files in a directory including hidden (also
known as dot files due to their prefix) files. List directories in long format (does not display files). Could add as a shell alias, say lsd. If you want to organise files by their modification date. ls -ltr If you are interested in knowing where on the disk files are stored, based on their inode, use the -i switch. ls -lia
|
|||||||||||||
| ll | |||||||||||||
| This command is exactly the same as entering
ls –al. The "ll" command is in fact an
alias to the ls command with the
-al switch. You can confirm this by
entering the
alias command. |
|||||||||||||
| less | |||||||||||||
| Scrollable command line, great for piping large
output into. The big difference between less and more is that you can scroll up
or down in the file you are viewing.
|
|||||||||||||
| more | |||||||||||||
| Exactly the same as DOS and Windows, also great
for piping large output into. For example, to view the contents of a file one
screen at a time more /etc/ssh/sshd_config Or, to pipe the output of a command into the more utility ls -al |more
|
|||||||||||||
| chown | |||||||||||||
| Changes file ownership. If only 1 user name is
specified then the user ownership is set only and the group ownership is left
unchanged as shown in the example below.
#chown ali solaris.vmx However if you wish to reset both the user owner and group owner, then rather than having to use chown and then chgrp straight after it, you can set user and group ownership in one operation by specifying the user owner and group owner separated by a colon as in the example shown. #chown ali:ali netware5.vmx
|
|||||||||||||
| chgrp | |||||||||||||
| Changes the group owner for a file, leaving the
user owner unchanged. In the following example, we have a virtual machine
configuration file w2k.vmx which has been created by the user bill. By default,
the permissions on the vmx file will be that the owner is the user bill, and the
group owner is the group called bill. Remember in Red Hat Linux we have user
private groups - every user account has a corresponding group of the same name! #ll Now we are going to change the group owner of the file to the group called vmadmins. #chgrp vmadmins w2k.vmx So, in a full file listing, when you see 2 names, e.g. bill vmadmins, the first name is the user owner and the second name is the group owner. In Red Hat Linux, we have something called user private groups, which means that for each user account, there is a group account of the same name. So if you see a file owner and group owner as the same name, these are not the same security principals, one is the user account, the other is a group of the same name.
|
|||||||||||||
| chmod | |||||||||||||
| The chmod utility is
used to change file permissions and so is similar to cacls.exe found in
Windows. We can use either letters
or numeric equivalency when setting permissions with
chmod. We can set permissions for 3
security principals, the user, the group and others (ugo). If you are from a Windows
background then don’t confuse “o” with owner.
When we look at a file listing using ls -al the file & directory permissions are shown on the left. -rwxr-xr-- 1 ali vmadmins 345 May 7 14:22 file.txt In the above example, the file has 3 permissions described in the -rwxr-xr-- string. These are: rwx for the User owner - in our example above, this is the
Linux user 'ali' In this first chmod example, we are going to change the permissions on the file.txt by removing the read & execute permission for the user owner of the file and we are also going to remove the read permission for the group owner of the file. # chmod u-wx,g-x file.txt Note that using + or – indicates we are adding to or removing from the existing permissions. If we wish to reset the permission we use “=” to explicitly set the object permissions, overwriting anything that was already set. # chmod u=rx,g=r,o=r file.txt yields r-xr—-r-- Sometimes you will see a chmod command 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
would
set permission to rwxrwxrwx
Watch for chmod commands with 4 digits, e.g. chmod 0754. This refers to additional attributes as described below. Sticky bit When the sticky bit (t) is set on executable files, it tells Linux to keep the application in memory. The reason for this is to improve load times for other users who wish to run the same executable. This relates to the multi-user nature of UNIX/Linux. Given the speed of memory and disk access nowadays the need to keep applications in memory is much less important and so the sticky bit isn't needed so much. When the sticky bit is turned on for a directory, users can have read and/or write permissions for that directory, but they can only remove or rename files that they own. If you see a "t" in a file or directory permission, this indicates the sticky bit is set. You can turn on the sticky bit with the chmod tool and specify "t". chmod +t /directory You can then view the directory with ls -al and note that the executable permissions indicator bit is shown as a "t" showing that the directory has the sticky bit set. drwxr-xr-t 2 root root 4096 May 7 12:02
directory SETUID (set uid) The Set User ID bit is used on an executable file, so that when it is run, it is run under the security context of the file owner and not the current user who launched that executable. So, if I have an executable file whose owner is 'root' and it has the setuid bit set, then when I run this application as a normal user, that application would still run under 'root' privilege. To set the UID bit, we use chmod with the "s" indicator. In the following example, the Perl script called listswitch.pl is has a user owner 'ali' and a group owner 'vmadmins'. Once the user id bit is set on this file, whoever launches the executable will not in fact be the owner of the process, the user 'ali' will be the process owner. # chmod u+s listswitch.pl You may have already been using a program with setuid set and not even known about it! The sudo command is owned by root and has the setuid bit set. You can check if the setuid bit is set by inspecting the file permissions ---s--x--x 1 root root 80764 Jul 23 2001 /usr/bin/sudo Set Group ID. Just like SUID, setting the SGID bit for a file sets your group ID to the file's group while the file is executing. So again, we use the chmod tool with 's' but this time we set it on the group permission. # chmod g+s listswitch.pl The group id bit is a great feature to enable easier management of permissions on the files in that directory. When the group id bit is set on a directory, any files or subdirectories created in that directory will automatically have their group ownership set to the same as the parent directory! As we have seen above, to set any of these 3 attributes, we can use the 't' and 's' indicators. However, often we set permissions with chmod using numerical values like 777 to represent rwx. When setting user id, group id or sticky bits using chmod and numerical values, we use a 4th digit preceding the usual 3 used with chmod. That digit is set using the following: 4 Set user ID (s) So if we want to set a file with permission -rwxr-xr-x and set the user ID bit we could use the following: # chmod 4755 which would result in a new file permission of -rwsr-xr-x. Notice the "x" of the user permission is now an "s" indicating the setuid bit is set.
|
|||||||||||||
| umask | |||||||||||||
| Another permissions feature you may encounter is
that of umask. This is set on a directory and acts as a permissions template
filter whereby default permissions on new objects are set based on what the
umask removes from the standard permissions. The most frequently used umask is 022, this would take away the write permission for the group owner and others in a permission list, i.e. full permission equals 777, corresponding to read(4), write(2) and execute (1). Full permissions
777 rwxrwxrwx
|
|||||||||||||
| VMware Command Line Tools
|
|||||||||||||
| vmkpcidivy | |||||||||||||
| A VMware tool. This is used to divide up the RAM and
physical PCI resources in a server between the service console and the
VMkernel. Either operating system can be assigned a PCI card or the PCI
card is shared between the two operating systems. For example, a typical
ESX server would have a division of physical PCI resources as: 1 NIC
assigned to Service Console The vmkpcidivy tool is stored in the directory /usr/sbin/vmkpcidivy. This tool asks a series of questions and should be used with the –i switch for interactive mode. To assign a PCI card to either operating system, we use the 3 characters c, v & s. [c] Assign to Service Console To run, we just type vmkpcidivy -i If you add a new NIC, SCSI or fibre channel PCI card to your physical server, you should boot the server into Linux and run the vmkpcidivy command. This way you can correctly assign the PCI card to the right operating system and also allows you to check that the new PCI card has not changed your existing PCI assignment. Once you have saved your changes, restart the server and boot ESX Server normally. This command is also used to refreshnames and –q vmhba_devs For example, if I had a SAN LUN of vmhba1:0:25 and lets say I removed the VMFS from this LUN and now wished to use it from the service console, I’d run # vmkpcidivy -refreshnames and then would run vmkpcidivy again this time with the query switch (-q) # vmkpcidivy -q vmhba_devs to find out what device name the service console was going to use for this LUN, e.g. vmhba0:0:0 /dev/sda A very useful feature of this tool is the ability to create a new profile. This adds a new boot option to the LILO boot menu that will have its own allocation of memory and PCI devices. If you are unsure about the changes you are making, then create a new profile e.g. esx (modified)
|
|||||||||||||
| vmkchdev | |||||||||||||
| This is a little known utility that is very
useful. The following use of the command vmkchdev -L lists the PCI devices and reports whether they are assigned to VMkernel or the service console. We can also get this information from running vmkpcidivy, but if we only want a quick report of which device is owned by which OS, then this is great. Notice also that the PCI device ID is reported which is very helpful where we have more than one device of the same name, e.g. you could have 2 dual port Intel ethernet cards.
|
|||||||||||||
| vmkfstools | |||||||||||||
| The vmkfstools utility is the tool for managing virtual disks.
Remember that to copy a file into a VMFS could have an adverse affect on other VMs with
virtual disks on the same LUN. We always want to avoid using file copy tools to populate a
VMFS. Copy operations will update the volume in 16k blocks causing unnecessary
SCSI reservations to update vmfs metadata. The switches that can be used with the command are listed below: -i to import a virtual disk to VMFS Remember that the vmfs parameter always goes last on this command parameter set for vmkfstools. This can be confusing for the beginner as the source and target order is different for imports and exports. If we want to simply list the files on a vmfs volumes we use the -l switch. vmkfstools –l /vmfs/vmhba0:0:0:8 or if we wish to use the more friendly VMFS volume label; vmkfstools –l <vmfs-metadatalabel> which would produce an output similar to the following Name: VMFS2-VOL1 (public) [root@esx4 W2Ktest]# vmkfstools -lh
vmhba0:0:0:10 To create a new VMFS volume, we use the -C switch. In the following example, we are creating a VMFS volume on LUN16 on host bus adapter 1, typically the fibre channel adapter. vmkfstools -C vmfs2 vmhba1:0:16:1 If someone has created a VMFS volume with an illegal character in the volume label, you may have problems removing that volume in the MUI. If this is the case, just overwrite the VMFS volume by creating a new volume over the top of the badly named one using the -C switch. To create a new empty virtual disk on a VMFS volume we use the -c switch vmkfstools –c 2048M /vmfs/vmhba0:0:0:8:newdisk.vmdk This command would create a new virtual disk (monolithic) on the specified VMFS volume. Remember it is always better to use the VMFS name as this will not change even if your hba hardware does. To import a virtual disk into the VMFS we use vmkfstools with the -i switch. This will take a virtual disk in sparse (COW) format into monolithic format without causing excessive SCSI reservations on the LUN holding the target VMFS. vmkfstools –i /vmimages/template.vmdk /vmfs/vmhba1:0:25:1/new-vm.vmdk As always with this command, the parameter specifying the VMFS location is always the last parameter. If you just wish to view the properties of a VMFS volume, you can use the -P switch to print the volume properties. You can use either the logical name for the vmhba partition or the VMFS volume label.
[root@esx1 cpu]# vmkfstools -P VMFS2-VOL1
|
|||||||||||||
| cos-rescan.sh | |||||||||||||
| This script calls vmkfstools command with the -s
switch. This is meant to be safer that directly executing vmkfstools -s as some
pre-checks are made.
|
|||||||||||||
| vmware-cmd | |||||||||||||
| A command line tool to perform VM operations, such
as power on and off or connect/disconnect devices. This tool always requires the
full path to the configuration file of the VM you wish to manipulate. This
tool is found in /usr/bin There is no man page for this tool and --help doesn't yield anything beyond simply entering the command without parameters. Some additional information is visible if you enter vmware-cmd -h The first thing we can look at is to registering and un-registering a VM. We use the "-s" switch to indicate we performing a server operation, as opposed to VM operation. vmware-cmd –s register /home/user/vmware/newvm/newvm.vmx vmware-cmd –s unregister /home/user/vmware/oldvm/oldvm.vmx The next use of this command is to list the VMs on the server. However, this will only list the registered VMs, i.e. the VMs which are listed in the file /etc/vmware/vm-list # vmware-cmd –l /home/vmware/vm1/vm1.vmx Next we are looking at connecting or disconnecting a device. Typically this will be for the connection of IDE CD-ROM ISO files or floppy image files. vmware-cmd /home/user/vmware/vm/vm.vmx connectdevice|disconnect To perform power operations we unsurprisingly use the start and stop parameters. A stop operation type can be soft, try soft or hard. A stop hard is the last resort and equivalent to a forced VM power off. Here is an example of starting and then soft stopping a VM. # vmware-cmd /home/user/vmware/server/server/vmx
start # vmware-cmd /home/user/vmware/server/server.vmx
stop soft If we wish to query the current heartbeat value for a VM, the getheartbeat parameter does the trick. Remember though, that in order to draw any meaning from this, we should query the heartbeat twice to prove the value is in fact increasing! For example, # vmware-cmd /home/user/vmware/server/server.vmx
getheartbeat # vmware-cmd /home/user/vmware/server/server.vmx
getstate To find out the VMID (also known as the world ID) of a VM, we can use the getid parameter. The VMID is analogous to process ID (PID) but is the unique ID that the VMkernel is using for the Virtual Machine Monitor. The VMID of a VM is normally a 3 digit number greater than 100. # vmware-cmd /home/user/vmware/server/server.vmx
getid For every VM that is running with a VMID in the VMkernel, there are a parallel set of management processes running in the service console. These processes are there to allow operators interact with the VM, for example, power on and off, gain remote console access and to maintain the per-VM logging in the file vmware.log. To find the parent process ID (PID) of the management processes that correspond to a VM, we can use the getpid parameter. # vmware-cmd /home/user/vmware/server/server.vmx
getpid Both the VMID and PID remain unchanged while the VM is running. Once the VM is powered off, those IDs are removed and the VM will more than likely get a new VMID and PID the next time it is powered on. We can also use this tool to answer questions such as the commit of a REDO file to virtual disk: vmware-cmd
"/home/vmware/SPPS 2003/SPPS 2003.vmx" answer
|
|||||||||||||
| vmkdump | |||||||||||||
| This is used to manage the VM kernel core dump
partition. We can change the partition used if required. This tool is also
needed if the core dump partition had been removed; because ESX expects it to be
there when starting up, so we need to tell ESX that it has gone.
vmkdump -q
Query the VM kernel for which
partition it will use Remember the vmkcore partition does not have a mount point in the service
console and is not specified as ext3. We can use the
fdisk -l command to view where the core dump
partition is in relation to the disk layout.
|
|||||||||||||
| vmkload_mod | |||||||||||||
| Allows viewing with the –l switch, loaded and
unloaded VMkernel modules. This command differs from
lsmod
which lists the modules loaded for the service console. This is a very good way
of differentiating what modules the kernel is using versus the ones used by
vmnix.
# vmkload_mod -l Name R/O Addr Length R/ |