Posts Tagged ‘Unix’

Reading List :: Sunday 23rd October 2011

Steve Yegge has posted a much more interesting followup to his reply-all Google+ critique post from a week or so ago. The fact that he trashed Google on G+ was tickling, and reply-all accidents are always entertaining. But underwhelmed as I am with Google+ it wasn’t exactly hot news. The follow up, a story from his time at Amazon about presenting to Jeff Bezos, is really good. I feel like Bezos is standing today where Gates once was – mythical, exalted, feared, respected – and this story is a decent testament to that. He might prefer a Jobs comparison (I don’t know), but I think Gates is more appropriate if Yegge’s tale is anything to go by.

On Jobs, what a remarkable piece of fortune related by Cringely this weekend. The classic 1995 Steve Jobs interview, the highlight of the uniformly excellent Triumph of the Nerds, an interview introduced with the phrase ‘Rivers of Blood’, has been discovered in its entirety. The full 64 minutes of an interview we’ve so far seen only about 6 minutes of is apparently going to become available in some form, and soon. Bob describes the footage as ‘essentially an unedited interview — definitely not the sort of thing you’d normally see on TV.  It’s me coaxing Steve into a great performance’. I can’t wait.

There’s a certain contingent of nerds who feel pretty bitter about Dennis Ritchie’s death being overshadowed by that of Steve Jobs, which has lead to some total horseshit commentary by a few free software assholes and some pretty thoughtless (and transparently biased) comparisons of influence. Now that those so inclined have got the blogger-BS out of their system, there have been some really nice and, importantly, balanced, professional takes surfacing on the influence of Ritchie’s work on the lives of billions across the globe. I particularly like the Economist piece, bookended with Jobs references for context. A fitting tribute.

DIY Linux Transmission Server

 

One of my favourite things about Linux is its ability to transform a formerly useless elderly computer into something really useful indeed. This is the first in a series of posts covering some great projects to breathe new life into old machines using Linux.

What’s the Project?

BitTorrent is a fantastically useful distribution mechanism – when downloading updated Linux distro ISOs, it regularly exceeds the speeds available through centralised (HTTP/FTP) download repositories, and the sharing of bandwidth and ease of distribution are a great fit for online communities and fan groups (Zappateers, for example). Unfortunately, BitTorrent tends to be a total disk I/O hog, constantly reading and writing tiny chunks of file all over your disk. This causes big slowdowns for all other running programs which need access to your hard disk, not to mention the stress it puts on the drive itself.

We’re going to use an old computer, GNU/Linux and the Transmission BitTorrent client to offload this resource-intensive process to a networked machine, freeing up your main machine to get on with business unfettered. Sacrificing convenience, however, is not an option. Therefore, we’re going to implement the following convenience features:

  • Administering the client through a web browser
  • Sharing content over the local network
  • Creating a zero-setup process for starting new transfers

(more…)

Schedule WordPress Backups Using Cron

I was contacted a couple of days back by a reader who wanted to add my super simple WordPress backup program to Cron, the Unix task scheduler, to create automated regular snapshots of his site. Backing up my website using the program is something I normally do by hand as part of my general system maintenance routine, but the program is easily incorporated in to Cron to run on a timer. Completely by coincidence, I suffered a WordPress plugin failure within a couple of days of creating the Cron job, and thanks to my now daily backups I was able to restore from a 10 hour old snapshot with the minimum of fuss. (more…)

Restore Hidden Files to OS X 10.7 Lion Finder

One step Lion takes in the direction of erasing the file system altogether is hiding the Library, System and other OS- and user-crucial directories in the Finder.

Obviously as power users we’re fully used to delving into the (already abstracted) file system of Mac OS X, and we want those folders back! Via this site, there is a Terminal command to restore access to these directories, but be warned that it comes with a caveat: by enabling access to these folders, you open up the whole filesystem including UNIX folders (etc, var…) and DS_Store files for view in the Finder.

In short, it’s way annoying, especially when browsing Linux volumes.

Irritating as having bits of the filesystem whipped away from prying eyes, I think I’m going to stick with Terminal for accessing those folders. TextWrangler can still browse them, and that’s enough for me. For those who want to see everything, and I mean everything:

$ defaults write com.apple.Finder AppleShowAllFiles YES

Mac OS X 10.7 Lion DOES Ship With X11

And I’ve got the eyes to prove it. There seems to be some concern online that Lion ‘ships’ (can we even say that any more?) without X11. Well, one of the first things I’ve checked out on my retail copy of Lion is X11, which is present as ever.

Open a Terminal window, type ‘xeyes’ at the prompt and you’ll see X11 staring right back at you.

This installed by default on my MacBook Pro, but if you find it missing from your installation you can install it from the ‘Packages’ folder on the Lion install USB key/DMG.

Super Simple WordPress Backup Program

Whatever you do with your computer, it’s absolutely vital to back up your data. Never is this more true than when you’re administering a website, where creating backups should be a well organised and regular procedure.

This site is no exception to that rule, so to help me out with my daily backups I’ve written a small program in the Python programming language which automates the process of archiving daily snapshots of my site. For peace of mind, I still prefer to launch and organise backups myself rather than use completely automatic solutions; this program helps make that process much quicker.

Download

You can download the program by right-clicking here and pressing ‘Save As’/’Save Target As’.

If you want to download straight to your Linux machine from the command line, use wget:

$ wget http://zebpedersen.co.uk/python/wordpressbackup

The program is designed to run under Linux, but theoretically it will work on any Unix system (Mac OS X, Solaris etc…) with Python installed.

Operation

All you need to feed the program is the path to your WordPress installation (the directory containing your wp-****.php files). The database login credentials are borrowed from WordPress, and the backup is placed in a date-stamped folder for easy archiving.

Each backup contains a dump of your MySQL database and a tarball of your installation directory – everything you need to restore your site in case of a disaster. The backup will be created in the folder from which you start the program.

To launch the program:

$ ./wordpressbackup /path/to/wordpress/installation

For example, if your site is located in the directory ‘/home/randymarsh/web’, the command would be:

$ ./wordpressbackup /home/randymarsh/web

If you need help or more information, use the help & about functions:

$ ./wordpressbackup help

$ ./wordpressbackup about

Hopefully this little script can help out anyone else like me who only trusts a backup they’ve done by hand. Enjoy!

 

MacBook Pro 13″ Ubuntu Linux Drivers & Installation

Ubuntu Linux made its way onto my 13″ MacBook Pro this week via external storage. While installing, I was armed with just the laptop itself and a wireless-only internet connection, a real problem given that Ubuntu doesn’t detect the WLAN card out of the box.

I put together a disc to get the machine up and running which includes the DKMS package and the WLAN & nVidia display drivers. It’s not a full collection of files needed to get the laptop playing perfectly with Ubuntu, but it takes care of the most important core functionality.

You can get hold of the ISO by following this link, and I’d also highly recommend reading up on this page, although I’ve outlined and expanded on what I consider to be the most useful pieces of information from it below. I used Ubuntu 11.04 on a 13″ MacBook Pro 7,1 for everything in this post.

(more…)

Mac OS X Terminal Alternative – iTerm 2

I was pointed to iTerm a couple of weeks ago by a commenter in response to a post about running Xterm in fullscreen under Mac OS X. The software is still in beta, so I’ve been road testing it to see if it could be a viable alternative to the Mac OS’ Terminal.app or Xterm.

I’m delighted to report that, although it is still in beta, iTerm 2 has proven to be very stable, and has a ton of features which I’m sure any CLI Mac user will be absolutely delighted with – in fact, I’ve made the switch from Terminal.app on all of my Macs. Here’s a quick preview of my three favourite features.

(more…)

Tutorial Series: Linux Command Line Basics

Last week, I published a seven part series of posts introducing some of the key concepts, commands and techniques of the Linux/Unix command line. Here’s an index of the topics covered to help you find what you’re after.

 

Linux Command Line Basics Part VII: Tunnelling Using SSH

Knowing basic *nix terminal commands is an absolute must for any computer pro. Whether you use Windows, Mac OS or Linux, you’re bound to face the command prompt at some stage, so here’s my crash course in CLI. In this final part of my guide to the basics of command line Linux I’ll show you how to tunnel an internet connection using SSH.

SSH Tunnelling

Tunnelling an internet connection using SSH has many uses – if you’re on a restricted network at school or work you might not have access to certain sites. By tunnelling to a remote machine you can bypass these restrictions, allowing access to any site. The reverse is also true – by tunnelling into a machine at school or work you can gain access to resources on its local network which might not ordinarily be available to external connections.

Opening the Connection

The link established between the local and remote machines is akin to using a proxy server – we’re going to tell the browser (Firefox) to route data through a port on the local machine which is forwarded a specified port on the remote server. Requests will be made by the remote server and the results forwarded back to your local computer.

You need to choose a port which isn’t reserved for a common service – usually a high number in the port range (in the screenshot below I’m using port 9999).

Opening the tunnel to the remote machine

The command line SSH options are:

$ ssh -C username@remotemachine -D [port number]

Using this method will open a remote Terminal session also – there are options to simply open the connection and return the command line immediately, but this way you won’t forget about your connection, and it’s easier to close it when you’re done (just exit the SSH session).

Now that the port is open for business we need to instruct the browser to use it. Launch Firefox and open the preferences window. Click the ‘Advanced’ tab & select ‘Network’.

Click ‘Settings…’ to open the connection options dialog box. Select ‘Manual proxy configuration’ in this dialog box.

Now set the ‘SOCKS Host’ to ‘localhost’ and the port to 9999, or whatever port you selected when you opened the SSH session. Your config page should look something like the screenshot below:

We’re done, so save the changes you’ve made and exit the Preferences window. One way you can test whether your connection is working is to visit an IP/location site such as http://whatismyipaddress.com/ and see where it places you on a map.

To end the connection, simply exit the SSH session as you would normally. Remember to change back the settings you altered in Firefox, or it won’t be able to access the internet.

And that concludes my crash course in *nix command line – we started learning about the file system and are very quickly forwarding connections, using remote GUI applications using X and more. Hopefully this has demonstrated just how powerful the command line interface can be, and by taking just a little time to become better acquainted you can start accomplishing some really cool stuff. Thanks for reading!

For a full list of topics covered in this tutorial series, head over to the index page.