/home » workblog

Entries for the ‘Linux/Unix’ Category

Firewalling an OpenVZ node and containers

The OpenVZ wiki has a nice script for firewalling an OpenVZ node and it’s containers. It creates a service and configures iptables to block all traffic to the node (except the ports you specify), but allow all traffic through to the containers, so that they can manage their own firewall. It also allows the container’s [...]

Relaying Qmail Through a Spam Filter

If you’re running a mail service on a web server so it can send out e-mail from contact forms, etc then you’ll want to make sure it’s relaying outbound mail through a spam filter, or it could be used to send spam if the forms get hijacked. For qmail, you just need to create /var/qmail/control/smtproutes [...]

Skipping Disk Check When Rebooting Linux Server

If you don’t run a disk check on a Linux server in awhile and you reboot, it may force a disk check, which can take 30+ minutes, and it’ll be offline the entire time. You can reboot and skip the check with shutdown -fr now or force a check with shutdown -Fr now. (via go2linux.org)

Convert Filenames to Lowercase on Linux

If you transfer files from a Windows server to a Linux one, you may get some broken links because Linux is case-sensative while Windows isn’t. You can rename all the files on the Linux server to their lowercase equivalents with this shell script from Linux Journal.

#!/bin/sh
# lowerit
# convert all file names in the current directory [...]

NTP Service Doesn’t Start Serving Until It Stablizes

I just spent an hour trying to figure out why the NTP service I installed wasn’t working, and then I came across this slightly important little fact:
Your internal workstation computers will not be able to use the server as a synchronisation source until the LOCAL(0) clock has stable time. This may take up to 15 minutes [...]

Find largest directories on a Linux box

These commands will return the largest 10 directories on a Linux box.

du -k / | sort -n | tail -10

via peterbe.com

Find recently modified files in Linux

This will list all the files on a Linux system that were modified in the past 5 days

find /path/to/start/at -mtime -5 -print

Finding a string inside multiple files on Linux

Snipplr has a good article on how to find all of the files on a Linux system that contain a specific string.

find /the/path/to/start/at |xargs grep 'the string' -sl

The search will include subfolders.

Installing the Oracle Library for PHP

Chris Sibert wrote a good tutorial on installing the Oracle library for PHP. If you’re running SELinux, I’d recommend temporarily turning it off to get the module setup so you don’t have to worry about problems during the install, and then turn SELinux back on after you verify the module is working. Then you can [...]

Set Linux time using remote time server

You can use the rdate command to set the correct time on a Linux system, instead of having to manually enter it. NIST has a list of time servers. You can then use hwclock to update the hardware clock.

rdate -s nist1-ny.WiTime.net
/sbin/hwclock –systohc