How to change a linux account password


I don’t dabble in Linux very much but had an issue with an account on a CentOS server and I’d forgotten how to reset a password

You need to be logged in as superuser i.e. root so that you are then able to change the password for any account.

The command is passwd:

passwd joebloggs

You should then be prompted to enter a new password and asked to confirm

How to install VMware tools on a Linux guest


I initially used the VMware guide http://www.vmware.com/support/ws5/doc/ws_newguest_tools_linux.html

From installing a few times on a variety of Linux flavours this is my interpretation.

In the Virtual Infrastructure right click on the Virtual Machine and select Guest and Install/Upgrade VMware Tools

image001

Click OK on the warning message

image002

The VMware tools are loaded as a CD/DVD drive in the guest Linux virtual machine. Ensure that you are logged in with root privileges, right click on the tar file and select Extract to

image003

Select an extraction location from the Extract in folder field. In this case I have chosen /tmp

image004

Once extraction is complete open a Terminal window and type cd /tmp

image005

The vmware-tools-distrib directory should exist inside the /tmp directory. Type

cd vmware-tools-distrib

image006

Next type

./vmware-install.pl

Answer the various configuration questions pressing Enter if you are happy to accept the default values

image007

Also take care choosing display resolution as certain applications require a minimum for installation

In this case I chose 1024 x 768

image008

Once completed you will need to restart X session to pick up the resolution

image009

A quick and easy way to restart is to use Ctrl-Alt and Backspace which will log you out of your desktop session

How to expand a system disk for a VMware virtual machine running a Linux OS hosted by a VMware Server


To increase a virtual machines system disk running a Linux OS is a two step process.

Firstly we need to expand the disk and then we need to increase the partition size inside the host.

Expand the disk

Turn off the virtual machine that you wish to administer.

Open a command prompt and change directory to C:’Program Files’VMWare’VMWare Server or C:’Program Files’VMware’VMware Workstation depending upon what product you are running.

Run this command to expand the virtual disk: vmware-vdiskmanager -x 20GB "My harddisk.vmdk"

In my case I would like to increase the disk to 20GB so substitute your value. Include the full file location for the vmdk file and use quotes if there are spaces in the folder and/or filename

image001

The disk expansion should complete successfully

image002

Increase the partition size

Download the GParted Live LiveCD available here http://gparted.sourceforge.net/livecd.php

Gnome Partition Editor is a small bootable livecd that we can use to boot your VMware virtual machine so that we can adjust the partition size using the Gparted utility

In VMware server, edit your machine settings and configure the CD-ROM to use the Gparted .iso file and ensure that it is also ‘connected at power on’

Power your virtual machine on. You may find that you also need to enter the virtual machines BIOS settings to change the boot order so that the CD-ROM drive is first on the list. To do this press F2 when you power on the virtual machine and select the ‘Boot’ option. – and + will change the items boot order sequence

image003

The iso image should now boot and the Gnome Partition Editor menu screen appears. Select the Gparted Live (Default settings) option

image004

When the ‘Package configuration’ screen appears select the ‘Don’t touch keymap’ option

image005

Select your language from the list when prompted

image006

Select the mode. Default is 0 ‘Continue to start X to use Gparted automatically’

image007

Once it completes the boot process the livecd GUI is loaded

image008

Select your partition and click on the resize/move button. As you can see the partition I want to resize is LVM2 and not supported by Gparted!

How to extend an LVM disk on a VMware virtual machine running a Linux OS


I have had a number of virtual linux machines that have run out of disk space and have found it difficult in the past to find one solution to increasing the virtual disk and expanding free space into a logical volume.

The most recent example was when I needed to extend from 8GB to 20GB and using the Gnome Partition Editor, Gparted, would not work as it doesn’t currently have LVM support.

There are some linux commands that get around this problem so first I extended the VMware virtual disk.

Expand the disk

Turn off the virtual machine that you wish to administer.

Open a command prompt and change directory to C:’Program Files’VMWare’VMWare Server or C:’Program Files’VMware’VMware Workstation depending upon what product you are running.

Run this command to expand the virtual disk: vmware-vdiskmanager -x 20GB "My harddisk.vmdk"

In my case I would like to increase the disk to 20GB so substitute your value. Include the full file location for the vmdk file and use quotes if there are spaces in the folder and/or filename

image001

The disk expansion should complete successfully

image002

Restart the VMware virtual machine and open a terminal session

Issue the df -k command which here shows us that the logical volume is at 100% usage

image003

We need to create a partition on /dev/sda

Type ls -al /dev/sda* which lists the existing partitions

image004

Our new partition will be /dev/sda3

Type fdisk /dev/sda then type’n’ for new partition

image005

Enter ‘p’ and 3 for the partition number (in this instance..obviously enter the partition number that matches your environment)

Also accept the default First and Last cylinders

image006

Finally type ‘w’ to write table to disk and exit

image007

If prompted to reboot then do so to ensure that the new partition table is written.

After a restart, type ls -al /dev/sda* to verify whether the new partition was created

image008

Now that the partition has been created we need to create a physical volume and add it to the volume group

Type pvcreate /dev/sda3

image009

Type vgextend VolGroup00 /dev/sda3

image010

We need to extend the logical volume

Type vgdisplay

image011

Which shows that there is 11.97GB free that we can add to the volume group

To extend the volume type lvextend -L+11.97G /dev/VolGroup00/LogVol00

I then had an error message that stated that there was ‘Insufficient free space: 384 extents needed but only 383 available’

After a quick search:

http://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/nofreeext.html

It seems that I needed to select a slightly smaller size. I selected 11GB rather than 11.97GB which solved this problem.

image012

Finally we need to resize the file system by typing resize2fs /dev/VolGroup00/LogVol00

image013

Type df -k to see if the new space is available to the logical volume

image014

The logical volume has now been resized and now has used space of just 35%!