The Linux Root Directory, Explained

It’s helpful to know the basic filesystem on a Linux machine, to better understand where everything is supposed to go, and where you should start looking if you want to find a certain file. Everything in Linux is stored in the “root directory”. On a windows machine, that would be equivalent to C:. C: is the main folder where everything is stored. On Linux we call this the “root directory”, or simply “/”. To go up to this root directory, type: ...

March 20, 2010 · 5 min · David Craddock

Useful OSX commands for Linux users

I wrote this list to remind me, as a newcomer to OSX, how the command line differed from the Linux commandline. I thought I’d expand on it, and share it: To mount any iso: hdiutil mount sample.iso To download a file as you would using wget: curl http://ftp.heanet.ie/pub/linuxmint.com/stable/8/LinuxMint-8.iso -o linuxmint.iso -C - the -o specifies the output file (required) the -C - specifies automatically resuming if possible. To burn a bootable iso to CD, DVD or USB key: use the “diskutil” program as described in: http://forums.macrumors.com/showthread.php?t=598291 Monitor disk io utilisation.. poll once per second ...

March 19, 2010 · 1 min · David Craddock

Long Bash History Files are Great.

When I’m installing software, or doing some complicated stuff on the linux command line, which nowadays is pretty much all the time, I will sometimes want to remember exactly what I typed. Now the normal /home/david/.bash_history file is usually fine for that. Run this command, for example, and you will see the commands you typed in before you logged out of the server last time you used it: cat ~/.bash_history You can also find out what you typed in this session, ie: since you logged in, by typing this: ...

March 18, 2010 · 3 min · David Craddock

My minimal VIM config

This is the absolute minimum I do when I have to log onto a new server or shell account that I haven’t used before, that I will need to edit text files with. First I figure out whether VIM is really installed. A lot of installs, especially those based on ubuntu, ship with VI aliased to VIM, but the VIM install is usually not really VIM at all, and behaves exactly like VI but with some minor bugs fixed. This is not what I want. ...

March 18, 2010 · 2 min · David Craddock

Using the Linux command 'Watch' to test Cron jobs and more

OK, so you have added a cron job that you want to perform a routine task every day at 6am. How do you test it? You probably don’t want to spend all night waiting for it to execute, and there’s every chance that when it does execute, you won’t be able to find out whether it is executing properly - the task might take 30 minutes to run, for example. So every time you debug it and want to test it again, you have to wait until 6am the following day. ...

March 13, 2010 · 5 min · David Craddock

Changing the default "From:" email address for emails sent via PHP on Linux

I’ve had to solve this problem a couple of times at least, and it’s quite a common task, so I thought I’d document it here. When you send emails to users of your site through using the PHP mail() function, they will sometimes turn up in the mailbox of customers of your site with the following from address: From: Root <root@apache.ecommercecompany.com> This makes absolutely no sense to your customers, and often they will think it is spam and delete it. Often, the decision will be made for them by their web mail host, such as hotmail.com or googlemail.com, and they will never even see the email. You don’t want this to happen. ...

March 10, 2010 · 2 min · David Craddock

Shell scripts for converting between Unix and Windows text file formats

I’ve been using these shell scripts I wrote to convert between unix and windows text file formats. They seem to work well without any problems. If you put them in the /usr/sbin/ directory, they will be accessible on the path of the linux admin account root. /usr/sbin/unix2win `#!/bin/bash Converts a unix text file to a windows text file. usage: unix2win requirements: sed version 4.2 or later, check with sed –version sed -i -e ’s/$/r/’ $1 ` ...

March 9, 2010 · 1 min · David Craddock

Site Redesign

I’ve just updated the design of this blog, re-enabled comments and added a contact tab. I’ve installed a strong anti-spam comment filter, but you should now be able to comment on entries. I’ve also changed the layout of things slightly, and made it easier to read.

January 14, 2010 · 1 min · David Craddock

PHP Sample - HTML Page Fetcher and Parser

Back in 2008, I wrote a PHP class that fetched an arbitary URL, parsed it, and coverted it into an PHP object with different attributes for the different elements of the page. I recently updated it and sent it along to a company that wanted a programming example to show I could code in PHP. I thought someone may well find a use for it - I’ve used the class in several different web scraping applications, and I found it handy. From the readme: ...

January 14, 2010 · 3 min · David Craddock

Passed the W3Schools PHP Certification

As a break from my contract work, I took the W3Schools PHP Certification. I didn’t do any revision, which probably wasn’t wise. It was a bit more difficult than I thought, but I passed still.

January 14, 2010 · 1 min · David Craddock