Archive | Linux

Update DynDNS from the command line

My router is not updating DynDNS correctly, so I wanted to use a simple cron job to do the same. Here is a simple BASH/Shell script to update DynDNS:

IP=$(curl -s
curl -v -k -u username:password “$IP”

How to setup a remote syslog server in CentOS 6

I wanted to have a cisco device send it’s logs to a Centos box for troubleshooting. I just wanted to do a “tail -f” against the error logs. Seems that syslog is now rsyslog in Centos 6. To setup rsyslog to accept syslog logs from other devices, you need to:

1. uncomment out the following lines (not the description lines, the ones that start with “$”)

# Provides UDP syslog reception
$UDPServerRun 514

# Provides TCP syslog reception
$InputTCPServerRun 514

2. Add a line or two like these below to say where you want the logs written:

:fromhost-ip,startswith,’192.168.1.’ /var/log/remote.log
& ~
:fromhost-ip,isequal,”″ /var/log/servername.log
& ~

3. service restart rsyslogd

4. add a hole in iptables for 514 (UDP and TCP)

-A INPUT -m state –state NEW -m udp -p udp –dport 514 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 514 -j ACCEPT

5. service iptables restart

6. create a new logrotate.d config file in /etc/logrotate.d:

rotate 5
/bin/kill -HUP `cat /var/run/ 2> /dev/null` 2> /dev/null || true

CentOS 6 in a VM – Console resolution

I can NEVER remember this, and every time I re-install CentOS in a VM I have to go searching.

If you want the console size to be larger in a vm add vga=791 (for 1024×768) to the end of the kernel line in /etc/grub.conf.

The VESA values (for linux) are here

How to add Gnome to a CentOS 6 minimal install

I have been using the minimal iso (CentOS-6.0-x86_64-minimal.iso) to install CentOS 6. I wanted to add a GUI to my vm, but I could not find easy documentation showing how to add a GUI, or Gnome in this case, to a CentOS 6 minimal install. I was not looking for the smallest X windows install, I was just trying to get the Desktop to function like it would as if I installed from the full DVD.

There are a lot of results of how to do this, but things have been renamed in CentOS 6, so that made it more difficult to figure out. Also, there are “Short Names” and I am assuming they are called “Long Names” associated with a yum groupinstall, which added to my confusion.

To add Gnome/GUI to a minimal CentOS 6 install run (short name version):

yum groupinstall basic-desktop desktop-platform x11 fonts

And the “long name” version:

yum groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts"

Hope that helps someone or at least help me to remember.

BASH script to email if WordPress plugins or themes need updating

This one took me all day. But I got it. I wanted to have a script that could look through all WordPress sites and find if there are outdated themes or plugins. All I need to do is slap it into a cron job and I am good to go!

Here is the BASH code to do it.



for installpath in $(find /var/www -name wp-config.php)
cd $(dirname $installpath)

THEMENEEDED=$(php -r 'require_once("./wp-load.php");
$new = get_site_transient("update_themes");
echo count($new->response);')

if [ ! $THEMENEEDED = 0 ]; then
UPDATESNEEDED="$UPDATESNEEDED \n Site $installpath needs $THEMENEEDED theme(s) updated"

PLUGSNEEDED=$(php -r 'require_once("./wp-load.php");
$new = get_site_transient("update_plugins");
echo count($new->response);')

if [ ! $PLUGSNEEDED = 0 ]; then
UPDATESNEEDED="$UPDATESNEEDED \n Site $installpath needs $PLUGSNEEDED plugin(s) updated"

if [ -n "$UPDATESNEEDED" ]; then
echo -e "$UPDATESNEEDED" | mail -s "Updates are needed" [email protected]

I have been needing this script for a while.

How the cloud failed me.

We host our Linux boxes on Rackspace’s Cloud Server platform. We pay extra per month to use their Redhat Linux images. In return we receive all our patches and updates through Rackspace’s RHN Satellite server. Our thinking was that, we could purchase a Redhat support contract, and  since we were running Redhat we would have OS/Application support if needed.

We were every happy with the service until the cloud failed me.

It all started when the new WordPress 3.2 required PHP 5.2.4 or higher. Redhat 5.5 only shipped with 5.1.x. I needed to update my Redhat VMs to 5.6 as Redhat 5.6 had PHP 5.3.x. BUT. Rackspace decided not to deploy 5.6. They said it is coming, but weeks later I still can’t access it.

They suggested I go to a non supported repo and install it from there. But that defeats the whole purpose of using Redhat on their VMs – I would not have a support path – Redhat would not support a package that was not in their repo (understandably).

I was forced to buy Redhat support contracts for my servers. Now, we are paying twice for updates, with a support contract and with Rackspace’s extra cost per VM for running Redhat.

We have all heard that “forced upgrades” is a downside of cloud services.

This is the opposite – their cloud service is holding me back.

How to remove a machine from a RHN Satellite

I wanted to move a VM from a RHN Satellite back to the default Red Hat Network. I found these two files contained all the info:


I just moved them aside and ran rhn_register to re-register the system.

Then I ran “yum clean all” to make yum happy

Rebuild your the default CentOS yum.repo.d folder

On a dev machine, somehow, I managed to erase my yum.repo.d contents. I wanted to rebuild the repo files back to their default. First you need to figure out what version you are using:

  • cat /etc/redhat-release

Then visit the correct release at :

  • navigate to the correct os/x86_64/CentOS/ directory (could be os/x86_64/CentOS/ i386/)
  • Download the following files to the server:
    • wget
    • wget
  • Then install the two rpms:
    • rpm -Uivh *.rpm
Should be back to the original shipping repo files.

php53 included in CentOS 5.6

I wish I read release notes, it would make my life easier. In my previous post, I was worried about CentOS 5.x not having a new enough version of PHP to run the soon to be release WordPress 3.2. Well, RedHat’s 5.6 release notes clearly say:

Version 5.3.3 of PHP is now available in Red Hat Enterprise Linux 5.6 as the separate php53 package

To move to the 5.3 version of PHP, I ran the following commands:

  • yum erase php\*
  • yum install php53 php53-gd php53-mysql php53-pdo php53-mbstring  php53-cli php53-devel php53-common php53-xml

That was easy.