The Temple of Fu

code, systems and games

Archive for the ‘RedHats’ Category

VMWare Server – Failed to lock the file

leave a comment »

Almost every time when the power goes out at my house I receive the following error when starting up an image that was already running when the lights went out.
‘Cannot open the disk ‘/path/to/machine.vmdk’ or one of the snapshot disks it depends on.
Reason: Failed to lock the file.’

This is due to a lock being held on the memory files within the directory listed in the error message.

#cd /path/tovm
#ls *lck
#rm -Rf *lck

Be careful with the rm -Rf command above please 😉 hope this helps someone sometime.

Written by lordfu

March 23, 2011 at 10:09 pm

Posted in Linux, Other, RedHats, Slackware

Linux – Checking Memory Usage / Getting Memory Information

leave a comment »

Memory is one of the most critical resource components on a server to ensure that the smooth and fast operation. Thus, the availability of adequate and abundant physical memory size is vital especially for any server, especially high load web host that are also running database servers such as Oracle or MySQL, which are famous for being memory intensive. Linux, including CentOS, come with several commands and tools to check memory usage on server.


The free command displays the amount of total, free and used physical memory (RAM) in the system, as well as, shows information on shared memory, buffers, cached memory and swap space used by the Linux kernel.

free -[options]

Example usage of free; This command will display information about physical memory in MB.

free -m

The following command will activate a continuous polling delay of 5 seconds apart and then display memory status in megabytes on the terminal. Any floating point number for delay can be specified.

free -m -s 5

Same with “free -m”, but -t switch will display a line containing the totals of physical memory and swap space.

free -t -m


The command vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. With the vmstat command, administrators can have instantaneous reports on memory usage.

vmstat -[options] [delay count]

Example usage of vmstat


The following command will display report based on averages since last reboot. The command will pool average system resources usage level for a sampling period of 5 seconds at interval of 5 seconds, except for the first result that is averages since the last reboot.

vmstat 5


The top command displays dynamic real-time view of the running tasks managed by kernel and system information in Linux system. The memory usage stats by top command include real-time live total, used and free physical memory and swap memory with their buffers and cached memory size respectively.


Using top is simple, simply type top at command shell, and constantly update stats page will be shown.

ps aux

The ps command reports a snapshot on information of the current active processes. Advantage of ps command is that system admins will be able to see where the memory is used. ps will show the percentage of memory resource that is used by each process or task running in the system. With this command, top memory hogging processes can be identified.

Syntax and example of ps aux

aux is actually already the options for ps command to see every process on the system. So the typical command to type the following in the command shell:

ps aux

To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:

ps aux | awk ‘{print $4″\t”$11}’ | sort | uniq -c | awk ‘{print $2″ “$1” “$3}’ | sort -nr


You can also use the DMIDECODE command line utility to check the ram speed and type:

Written by lordfu

January 27, 2011 at 9:39 am

yum command: Update / Install Packages Under Redhat Enterprise / CentOS Linux Version 5.x

with one comment

Rather than r-epost what already is an excellent post I will just link you to it.

I will however add the following.

If problems occur while performing an update (for example broken packages) just tell yum to skip them
yum install updates --skip-broken

Written by lordfu

December 9, 2010 at 9:35 am

Posted in Linux, RedHats

CentOS 5* VSFTPD Install and Setup + OpenSSL

leave a comment »

Install VSFTPD
# yum install vsftpd

Turn on the VSFTPD service so it starts at boot
# chkconfig vsftpd on

Start, stop or restart VSFTPD
# service vsftpd [start,stop,restart]

Generate an OpenSSL certificate

You use OpenSSL to generate a certificate for vsftpd. The certificate is stored on your server, in a location of your choice. Here I choose to put it in the /etc/vsftpd directory. As well, you specify a ‘lifetime’ for the certificate; here it is set for 5 years (“-days 1825”).Note that the backslashes only signify line breaks. You should be able to copy/paste & run it as it is, or remove the backslashes and the line breaks.
If /etc/vsftpd does not exist create it (it existed on my system after install).
#mkdir /etc/vsftpd

#openssl req -x509 -nodes -days 1825 -newkey rsa:1024 \
-keyout /etc/vsftpd/vsftpd.pem \
-out /etc/vsftpd/vsftpd.pem

You will be prompted with a series of question, which you answer as they appear. When done the certificate will be installed in the /etc/vsftpd directory.

To configure vsftpd you need to edit the file /etc/vsftpd/vsftpd.conf and add the following lines:

Restart vsftpd for these settings to take effect:
#/etc/rc.d/init.d/vsftpd restart

Connect using a ftp client that support AUTH TLS / SSL / SFTP I use FileZilla.

Error Messages (below answers are what worked for me YMMV):
Connection attempt failed with “ECONNREFUSED – Connection refused by server”.
Provide correct info for login and port within your client.

Status: Connection established, initializing TLS…
Error: Connection timed out

I indicated the server type in my client as “FTPS – FTP over implicit TLS/SSL” but it must be “FTPES – FTP over explicit TLS/SSL” for it to work

Error: GnuTLS error -8: A record packet with illegal version was received.
Error: Disconnected from server: ECONNABORTED – Connection aborted

Verify vsftpd.conf settings are correct.

Written by lordfu

November 2, 2010 at 10:46 am

Posted in Linux, RedHats

Start MySQL daemon on boot

leave a comment »

In order to start the MySQL daemon at boot time one must add it to the system’s boot up process. Note this only works on SysV init runlevel systems.

Run the following command as root.

chkconfig mysqld on
or the more verbose where you specify the runlevel
chkconfig mysqld --level 2345 on

To clarify, a runlevel determines what services are started when a Linux computer is booted. When you boot into runlevel 1, only the core system files are loaded similar to Windows Safe Mode. Runlevel 2 is there if you want to create a custom runlevel the same as Runlevel 4. Runlevel 3 is what most servers boot to and it starts all of your services and other things required for a true multi-user environment. Runlevel 5 is for starting a GUI and this is what most desktop systems boot to.

You can then check that MySQL is enabled to start by running the following command. Again run this command as root.

chkconfig --list

That’s it!

Written by lordfu

March 20, 2010 at 11:26 pm

Posted in Database, MySQL, RedHats

Reset MySQL root password

with one comment

#service mysqld stop
#/usr/bin/mysqld_safe --skip-grant-tables &
#mysql --user=root mysql
mysql>update user set Password=PASSWORD('new-password-here') WHERE User='root';
mysql>flush privileges;

Kill the mysqld_safe process


Then restart MySQL
#service mysqld restart

Written by lordfu

March 20, 2010 at 11:25 pm

CentOS 5 – QmailToaster Virtual Appliance – Install and Setup

with one comment

This is the first time I have ever used an appliance of any sort. I have always had a gut feeling it was wrong to let someone “build” my system for me but after a day of playing with this I must say how impressed I actually am. This was so easy. These are the notes from me installing the virtual appliance QmailToaster

Get QmailToaster from here

I installed this virtual appliance onto a CentOS 5.1 Linux host running the free version of VmWare server.

QmailToaster is a full blown turnkey mail solution built on the CentOS 4.3 release, it does not have VmWare tools installed and is allocated 384MB of RAM initially. The following packages are not shipped with the virtual appliance:

  • Qmail
  • SquirrelMail
  • SpamAssassin
  • ClamAV
  • Courier IMAP

This is due to the Qmail license, so they can’t distribute binaries. So the install of these applications are automated after boot through download and then compiled.

Features of this appliance are:

  • Source RPM packages ready for RPM based distributions
  • Domainkeys and SPF “Sender Policy Framework”
  • Integrated SpamAssassin, ClamAV and Simscan
  • Warlord virus and worm loader realtime scanning
  • CHKUSER 2.0 functions for qmail-smtpd
  • Qmail-Tap provides email archive capability
  • Virtual Domains (MySQL), Virtual Users (MySQL)
  • Autoresponder, Mailing List
  • Web-based email system, Web-based administration tools

Install the appliance

I created a guest inside VmWare and set it to boot from the downloaded ISO file from above. The settings I changed before booting the guest was removing the cdrom and usb device and then adjusting the network interface to use bridged networking. Bridged networking allows me to use the NIC within the virtual appliance as if it physically had one i.e.(I can give the NIC of the appliance its own unique IP address).

I then booted and watched. It runs through its’ normal install routine and then reboots.

Roots password is ‘password’ (with no single quotes), so login and change it!

I then ran /usr/sbin/timeconfig and set my timezone.

Changed the hostname and networking information.

Edit the following two files adding in your desired hostname in place of localhost.localdomain:
  #nano /etc/sysconfig/network
  #nano /etc/sysconfig/network-scripts/ifcfg-eth0

I configured Apache to operate on the new network information.

I have a local name server so I configured resolvers.

I changed default password for the admin-toaster web interface.

To log into http://localip/admin-toaster/ you’ll need to login to the command line and
change the password manually. The plain-text password should be located in but you can
also change it this way:
htpasswd -bc /usr/share/toaster/include/admin.htpasswd admin mynewpassword

I played with SquirrelMail located at http://localip/webmail/.

I updated the machine
#yum -y update

There is a separate smtp service running on port 587 just for smtp-auth. That service uses a different tcp.smtp.cdb file which allows all connections, it also does no rbl checking. I had to open port 587 on my firewall and have my client software(Thunderbird,Outlook,etc) use port 587 for outgoing mail. I did not however want to configure this on sendmail for all my servers that ship logs. I do use my mail server for relaying logs to a separate account. I had to do this.

I removed the apache docs (don’t know why I did)
#cd /var/www/ && rm -Rf manual

I changed the root password to mysql. I searched the net to try and find the default pass but could not find one, so I did it like this.

I changed the password for the vpopmail user’s access to MySQL

#nano /home/vpopmail/etc/vpopmail.mysql
#echo "GRANT ALL ON vpopmail.* TO vpopmail@localhost IDENTIFIED BY 'PUTNEWPASSHERE';" | mysql -u root -p

Written by lordfu

March 8, 2010 at 12:06 am

Posted in Linux, RedHats