This is a one liner that I use just about every day at work to:
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
Found thanks to this how to show the memory usage per process thread on LinuxQuestions.org

This is a one liner that I use just about every day at work to:
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
Found thanks to this how to show the memory usage per process thread on LinuxQuestions.org

I’ve recently been getting into learning to write WordPress plugins, which is surprisingly simple, once you find a good tutorial or two to go along with the WordPress Codex.
That proved difficult. So below I’ve got three decent tutorials that got me pointed in the right direction. All three were found on Tutsplus which is a great site overall.
Create WordPress Plugins with OOP Techniques – This was the first one I found which helped me to start understand what was going on with WordPress plugins.
Creating a Random Quote Plugin for WordPress – This one goes real quick, and doesn’t go into deep detail of what is actually going on. However, the code is straightforward enough that it’s easy to put together, especially if having gone through the Create WordPress Plugins with OOP Techniques link before hand.
Random Quote Plugin with Custom Post Type – This last one builds off of the previous random quote plugin tutorial and gives a little insight into custom post types and working with the dashboard.

This is actually a pretty much distribution agnostic description of how to change the time zone for your Linux system. Your time zone is controlled by the /etc/localtime file. However this file contains the information that files in /usr/share/zoneinfo contain.
First you will want to find the location of your appropriate time zone in /usr/share/zoneinfo.
Say for example you live in the US in the Central time zone the file you are looking for is located in:
/usr/share/zoneinfo/US/Central
With that information first we’re going to make a backup of the original localtime file and then make a symbolic link between the /usr/share/zoneinfo/yourtimezone and /etc/localtime files. For the example below I’m using the time zone example from above, make sure to replace it with your own.
cp /etc/localtime{,.bak} ; ln -s /usr/share/zoneinfo/US/Central /etc/localtime
Next we want ntpd to restart with this information so that our system time updates appropriately.
service ntpd force-reload

With the release of WordPress 3.5 I’ve been spending a lot of time at my new job troubleshooting issues with WordPress installations. Nine times out of ten folks, the problem is with the most recent plugin that you installed.
Start here WordPress Codex : Troubleshooting.
If you still have access to wp-admin go in and disable every plugin. YES ALL OF THEM FOLKS!
If the problem has stopped occurring after you’ve done that individually re-enable each plugin until the problem occurs again. Once you have found the problem plugin check to see if an update or fix is available. If there isn’t one let the developer know about it so that if they need to update their plugin they can.
If disabling your plugins didn’t fix the issue they still may be the cause of the problem. I’ve noticed that WP Super Cache can cause this frequently.
Log into your web server / host via SSH. Change to the directory that houses your WordPress installation and run the following commands.
mkidr wp-content/plugins.bak ; mv wp-content/plugins/* wp-content/plugins.bak
This will create a new directory called plugins.bak and move all of your plugins into it, effectively keeping WordPress from seeing and trying to load them.
Now one by one do the following:
mv wp-content/plugins.bak/pluginname wp-content/plugins/
Where pluginname is the name of the plugin’s directory. Each time you move a plugin from the plugin.bak directory to the plugins directory, go into wp-admin and enable that plugin.
Keep doing this until things break again. The plugin that causes the break is the one you will want to keep in the plugins.bak directory. The rest of them you can move over using the line from above.
Follow up with the developer like in step 1.
At this point it probably isn’t a plugin causing the issue.
Enable the Twenty Eleven or Twenty Ten default theme and see if the issue is resolved. Again if it turns out the issue is with the theme contact the theme’s developer for further assistance.
You’ve gotten this far, you’re probably in a bad place.
At this point your best bet is to write down a list of your themes and plugins you have installed. Then backup your database. Follow the guide at WordPress Codex – Backing Up Your Database to do this.
Once those two steps are done you will want to delete your entire WordPress installation and re-install. Once the WordPress installation has been re-installed restore the data in your database using the instructions in the link above. Then, one-by-one re-download your themes and plugins and activate them.
Call a professional. If this still hasn’t resolved your problem please contact a professional WordPress developer. They will have to investigate the problem further. It may be a data issue.

Just about everyone has their own way of configuring Apache. This is my basic installation and configuration that I generally follow.
Thanks to yum installation is incredibly easy. At some point in the future I may go over installation via tar ball. For now though the following command is all you need.
yum install httpd
While not necessarily a requirement as Apache will still work appropriately without it, it is good practice.
echo "HOSTNAME=yourhost" >> /etc/sysconfig/network
hostname "yourhost"
Obviously replace yourhost with your actual server’s hostname. Make sure not to use something silly like www or the same as your domain name.
That just sets your host’s name. We still need to make sure the fully qualified domain name is set. Using vi or nano open /etc/hosts and make sure the following two lines are in there.
127.0.0.1 localhost.localdomain localhost
your.ip.ad.dress yourhost.yourdomain.tld yourhost
A slightly better example based off my actual server’s /etc/hosts file is below.
127.0.0.1 localhost.localdomain localhost
199.21.115.213 web.blu-web.com web
Again, this is another not necessary step but is good practice in my book.
chkconfig --levels 235 httpd on
I’m not going to go into details as to what each run level is I will however point you in the direction of the Wikipedia article on runlevels.
Another good practice. We won’t be making any adjustments to the httpd.conf in this guide, but I prefer having this backup for when I inevitably do something goofy in the future I am able to recover from it quickly.
cp /etc/httpd/conf/httpd.conf{,.bak}
After this we will have a fully functioning Apache installation. You could stop reading after this, but you don’t want to.
service httpd start
Good you kept reading, I’m proud of you.
Most people store their files in the same old boring spot /var/www. I prefer /srv/www.
The basic structure I’ve stolen from the Linode docs. Which by the way you should definitely check out. It’s very similar to this guide in a slightly different order.
mkdir -p /srv/www/yourdomain.tld/public
mkdir -p /srv/www/yourdomain.tld/logs
This allows us to have our domain specific logs in a specific spot and makes it easier to separate any publicly accessibly files from the private ones if using server side scripting.
We want to make sure that our directories are owned by the correct user so that files can be properly served and if uploads are required they can be done easily. This is a basic configuration though, so remember there is much more to this than what you see here. Please do your own research on this subject to determine what is necessary for your own production environment.
chown -R apache: /srv/www
Next we need to create our first virtual host, which will tell Apache how to serve our particular web site on the server. Again this is a simple one.
vi /etc/httpd/conf.d/yourdomain.tld
Use whichever editor you want for this obviously, and replace yourdomain.tld with your actaul domain that you will be hosting.
<VirtualHost your.ip.ad.dress:80>
ServerName yourdomainn.tld
ServerAlias www.yourdomain.tld
DocumentRoot /srv/www/yourdomain.tld/public/
ErrorLog /srv/www/yourdomain.tld/logs/error.log
CustomLog /srv/www/yourdomain.tld/logs/access.log combined
</VirtualHost>
When making changes to a virtual host file or to your httpd.conf you will typically want to reload the configuration files rather than restarting Apache. Restarting Apache causes it to stop and if your configuration file is malformed it will not restart. By reloading Apache it will attempt to load the new configuration in and if it is not able to it will continue using the old configuration.
service httpd reload
Lets make a quick test page to make sure everything is working.
echo "Success" > /srv/www/yourdomain.tld/public/index.html
Now open up your browser and navigate to your domain and you should see a web page saying “Success”.
If it doesn’t you skipped a step…or I forgot something in this guide. In which case please call me out on it so I can correct it.
There are a lot of guides on installing Webmin on different distributions and even for CentOS already. But it’s time for another.
The first thing we have to do is configure a repo for Yum to pull from. You could use your favorite text editor to write out the file… or be awesome and just use cat. Either way be sure to save it to /etc/yum.repos.d/webmin.repo.
webmin.repo contents
[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
EOF
Using Cat
cat > /etc/yum.repos.d/webmin.repo << EOF
[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
EOF
Next we need to download the GPG key for the repo and import it. The code below changes to your home directory “cd ~“, then downloads the GPG key “wget http://www.webmin.com/jcameron-key.asc“, next it imports the key “rpm --import jcameron-key.asc“, and finally cleans up a little bit and gets rid of the GPG key “rm -f jcameron-key.asc“. The “&&” tell bash to run the next command only if the previous one was successful and the “;” tells bash to run the next command regardless if it completes or not.
cd ~ ; wget http://www.webmin.com/jcameron-key.asc && rpm --import jcameron-key.asc && rm -f jcameron-key.asc
At this point we can now let handle the installation for us.
yum install webmin
Even though its installed and the service was probably started, probably had the correct run levels set for it, it’s still a good idea to go ahead and make sure.
## ADD WEBMIN TO CHKCONFIG ##
chkconfig --add webmin
## SET THE RUNLEVELS FOR WEBMIN ##
chkconfig --level 3 webmin
chkconfig --level 5 webmin
## START THE WEBMIN SERVICE ##
service webmin start
By default Webmin serves from port 10000. However by default port 10000 is not open by iptables. Also a heads up I know I insert (which puts the rule at the top of the iptables rule list) instead of append (which puts it at the bottom). That’s because there is a rule already in the iptables input chain that is above where this rule would go into should I do an append with it that blocks all the traffic. So we put this one at the top and say allow it.
## ADD IPTABLES RULE ##
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 10000 -j ACCEPT
## SAVE THE RULE TO IPTABLES ##
iptables-save
## RESTART IPTABLES ##
service iptables restart
Or something like it. You should be able to browse to http://localhost:10000 or your http://yourserverip:10000 or http://yourhostname:10000 and login with your system’s root password.
Check out my EasyConfigure – Webmin for CentOS 6.3 script which is a part of my EasyConfigure scripts repo on GitHub.

After the catastrophe that happened last week with my VPS host where all my data was lost, I’m going to rebuilding this series on doing basic configurations of different services on CentOS 6. The majority will all tie in together and I’m going to be going through them such that the dependencies are done first.
The very base of all of this is making sure the EPEL repository is available.
Out of the box with CentOS 6 the EPEL repository isn’t enabled, even though I use it so much I’m of the opinion it probably should be.
It’s super simple add a repository. Most repo’s provide and RPM package that can be installed. EPEL isn’t an exception.
rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
This command has four parts that I’m going to go over real quick.
rpm, which you can read more about in the man pages, is the underlying package manager to yum. A lot like dpkg is the back end to apt on Debian systems.
The U in the Uvh tell’s rpm to upgrade the package if it doesn’t already exist. This is the one option on the string that is needed / should probably be used in case you already have the package installed it will just update it to the most recent version.
The v and h tells rpm to direct what it’s doing to the screen and to use hash marks for the installation progress of the package. These are not needed necessarily needed.
Finally you’ll noticed instead of pointing to a local package it points to a URL, rpm is able to pull packages down remotely and install them.
That’s all there is to it.
Keep an eye out as I put more guides up in the CentOS 6 Basic Configurations series.
