Author Archives: Randy

Migrating from Rackspace Cloud to Cpanel

Fed up with cloud hosting? You’re not alone. Just recently, I assisted a mass exodus of over 50 mysql/joomla based sites. After the migration to just a modest dedicated server with Cpanel, MySQL queries improved by 200% on average. Some longer queries and page loading times saw improvement of over 1000%. Additionally, the dedicated server […]

Easy Javascript-based Bookmark Link

Here’s a simple Javascript-based bookmarking script for your site. It automatically populates the page name and URL so you don’t have to. Put this in the <HEAD>: <script language=”javascript” type=”text/javascript”> function addToFav() { if(window.sidebar){ window.sidebar.addPanel(document.title, this.location,””); }else{ window.external.AddFavorite(this.location,document.title); } } </script> Then, you can add a link in your <BODY>: Bookmark Us!

Sysctl and ip_conntrack_max optimization

On a busy webserver, you have to be very careful that you don’t run out of connection tracking buckets. Check how many you have set as your max: /sbin/sysctl net.ipv4.ip_conntrack_max Check how many you’re using: wc -l /proc/net/ip_conntrack A good maximum setting for most web servers with at least 2Gb RAM is 65536. Change the […]

Bash: How to add a line on top of text files with sed

Sometimes you might need to add one or more lines of text to the top of an existing text file. Let ‘sed’ rescue you: sed -i ‘1iSTUFF TO ADD’ file.txt You can add multiple lines (separated by \n) to multiple files at once: sed -i ‘1iSTUFF TO ADD\nMORE STUFF’ *.txt

Categories: Code, Linux, and Technical. Comments Off on Bash: How to add a line on top of text files with sed

Find files modified/created within N days ago

This proved to be useful in cleaning up a compromised site. List all the files created or modified within a certain time frame — in this case we are looking 30 days in the past: find . -mtime -30 -type f -print If you want to delete all files created/modified n days ago, you can […]

Sorting disk usage by folder in Linux

Normally you would use something like this: du -k | sort -nr > sorted.txt But the output is not pretty since we don’t like counting bytes. This will sort it in human readable format: du -k | sort -nr | awk ‘ BEGIN { split(“KB,MB,GB,TB”, Units, “,”); } { u = 1; while ($1 >= […]

Categories: Uncategorized. Comments Off on Sorting disk usage by folder in Linux