Zero In on Disk Hogs With ncdu

NCDU ScreenshotI came across this tool recently, which I have been very impressed with. Though not really for every-day use, ncdu can be very helpful when tuning up your boxen, as you can quickly scan through multiple hard drives to find where all your disk space is going.

To use it, simply enter / in the prompt (start it up with no arguments), and make sure the “One filesystem” option is not checked (pressing X checks or unchecks it). Note that the backspace key actually did a forward-backspace for me (it deletes items in front of the cursor, rather than behind, as I’m accustomed). This may just be that my terminal isn’t set up properly (Mac Terminal connecting to a Ubuntu box as xterm-color), so YMMV. Let it run for it a bit (a progress window appears showing it going through all of your disks and folders). On my Ubuntu machine with a pair of SATA drives (software RAID 1), it took less than 30 seconds to go through everything.

[Read more...]

Advanced Bash Features

Bash is probably the most popular shell, and is often the default shell in many Linux systems. In addition to features like tab completion, redirection and scripting functions which are popular, there are also many less commonly-known features which can be quite useful. Many of these advanced features are introduced in this guide (see also Part II).

There are two features in particular that I find particularly useful. First is the various history features in bash. Typing `history’ will give you the commands you’ve entered in the order they were entered. However there are many other ways to access the command history:

This brings us to bang-bang or !!. !! tells bash “repeat the last command I entered.” But the magic doesn’t stop there, if you order now, you’ll also receive !xyz. !xyz will allow you to run the last command beginning with xyz that you typed. Be sure to add enough to the abbreviation to make it unique or you could run into problems, for instance: In the example above, ps was ran twice, then pwd. If you typed !p you’d get the output of pwd. Typing !ps is just enough to be unique and will execute the ps -auxw | grep http entry in history. By typing just enough to make your history request unique, give you a much better chance of hitting your targeted command.

Another nice feature is the ability to move around and delete words using keyboard commands:

Once again, bash comes through for us. Here are some of the movement keystrokes that I use most often:

  • ^w erase word
  • ^u erase from here to beginning of the line (I use this ALL the time.)
  • ^a move the cursor to the beginning of the line
  • ^e move the cursor to the end of the line

There are more of course, but those are the ones you simply can’t live without. For those who don’t know the ^N notation means ctrl+N, don’t confuse it with hats mentioned above.

This guide also discusses some other nice tools like brace expansion, bash functions and aliases.

Additional Reading:

How to Setup the Zonet ZPS1000 Print Server on Mac or Windows

Zonet ZPS1000Recently, I had to setup a Zonet ZPS1000 Pocket-Sized Print Server for an aging ink jet printer (specifically, a Canon i550) which I got from NewEgg (notice the watermark?). If you’ve had the “pleasure” of using one of these things in the past, you’ll appreciate how difficult the setup process can be. Don’t get me wrong: the device works quite well (so far) once setup. The problem stems from very poor documentation, obviously written by someone whose first language isn’t English. In this article, I thought I’d take you through the steps in setting one of these devices up on either a Mac or a Windows machine. I had such difficulty doing it myself that I figured others out there might benefit from this as well.

[Read more...]

Our new phone system

Asterisk LogoSorry we haven’t been updating the blog as often as we have been in the past – as always, things come up and stuff like this gets pushed to the side. But, as an update, I thought I’d talk about our new phone system today, and an introduction to how we got the Asterisk PBX up and running (I say introduction, because it’s a long process that will no doubt span multiple postings).

A while back we decided we would like to build a new phone system for Draconis – something that could grow as our needs grow, and versatile enough that could keep up with us. Our first thought was to use the open source Asterisk PBX, and as a result, we began building a phone system around this remarkable project. I’m going to give an intro to what we decided to build, but getting Asterisk up and running (especially if you don’t know a whole lot about phone systems) can be incredibly time-consuming. But, at least for us, it was also very fun.

[Read more...]

Uses of GNU Screen

A relatively under-used and unknown tool, GNU Screen has been gathering more interest as of late. Screen is described as a “terminal multiplexer”, a somewhat complicated way of saying that it lets you run multiple Unix-based console applications within a single terminal. In practical use this is done with separate “windows”, which are different views within the same terminal. For example, you could have one window connected to your email client, one monitoring recent syslog events, and one executing a build. Actions like creating, deleting and switching between windows are done through simple key combinations.

In addition to this, you can also keep screen running even after you close your connection, and then restart the session again later. This is a feature that I’ve found to be incredible useful. It allows me to, for example, detach my screen session when I leave work, and then restart it at home continuing right where I left off, with each window intact. You could also use screen to keep multiple connections open to various machines, although there are potential security issues with this.

There are a number of other neat features of screen, some of which are described in this tutorial from Kuro5hin. Another more detailed tutorial can be found here. One feature I especially like is the ability to have split screens, so you could do something like viewing the output of a number of logfiles all at once.

A recent Linux.com article discusses using screen for remote interaction. Screen can allow multiple users to access the same session, at the same time. This provides a simple way of doing “distance education”, as well as remote demos and tutorials.

Although screen isn’t the most widely known GNU program, it’s one of those utilities that once you start using it, you can’t imagine life without it.

The networker's lifeline: maximizing battery life

Thought I’d take a moment to point out several resources you should checkout if you spend any amount of time traveling with your laptop (or any electronic device, for that matter). Many sysadmins rely on their electronic devices, and losing laptop battery power while far from an electrical plug could mean big trouble for users.

So, if you want to stay connected, follow these tips.

[Read more...]

Cross-platform automated backups

Today marks the last day of our backups week. Hopefully by now you’ve realized how important it is to keep updated backups of your important files, and, as this weeklong feature has hopefully demonstrated, getting a working, efficient backup system into place is anything but difficult.

So far this week we’ve discussed how to setup and use rsync on Linux, Solaris, Windows, and MacOS X to create a useful, automated backups system. We’ve focused on using a single Linux box as the rsync server, but that doesn’t have to be the case: any of these platforms (and others, as rsync has been ported to many different platforms) can be used as an rsync server with nearly identical setup to that which we’ve already explored.

[Read more...]

Automated backups in MacOS X

It’s day four of backups week at the Draconis Blog, and today we’re going to be taking a look at the MacOS. Similar to the Linux setup, getting rsync to work on MacOS X is very easy (it should already be installed with your system).

If you’ve been following along, you’ll notice there are lots of similarities between the different platforms we’ve covered (Linux, Solaris, and Windows) and today’s focus is on the Mac. The main issues we faced are slight platform discrepencies (i.e. using Scheduled Tasks in Windows over cron, directory path names, and using the Cygwin tool in Windows), but using rsync has been universal. And today is no different.

As a quick recap, we have a single Linux rsync server setup to facilitate the transfers between any other computer on the network. This Linux box has plenty of free disk space (mounted at /backups) and has a different rsync profile for each host. Remember also that transferring to the server or from the server makes little difference, as far as rsync is concerned.

[Read more...]

Automated backups in Windows

It’s day three in our week-long exposè on automated backups, and today we’re taking a look at rsync in Windows. If you’ve been following along, you’ll notice setting up rsync in Windows is nearly identical to setting it up under Linux or Solaris (or MacOS, as we’ll look at tomorrow). The trick is to use the great Linux command-line emulator Cygwin, which creates a Linux “environment” on top of Windows. This article will take you through the installation process for Cygwin, and setting up rsync to automatically back up your important documents.

In the first installment of this series, we discussed how rsync communicates – there’s a server and a client, though which is which often doesn’t particularly matter. For our purposes, I’m using a Linux box as the rsync server and transferring all my documents there (and, as we saw yesterday, you can both send and receive documents regardless of which computer is the server).

[Read more...]

Backups in Solaris using rsync

It’s day two in our backups week, and today we’ll be looking at automated backups in Solaris. As I mentioned previously, we’ll be using the rsync tool to regularly send important files over to a Linux server for safekeeping (as well as to keep an additional copy locally).

Setting up rsync in a Solaris environment is very easy (and, naturally, is almost identical to setting it up under Linux). We’ll be sending the important files over to Linux, but there’s actually an additional wrinkle: my Solaris box has a very large RAID storage system (this happens to be a Sun E250 with several SCSI disks builtin – so I have about 50 gigs of space left over that I’m not otherwise using), and I’d like to keep another copy of my Linux backups on my Solaris box – backups of backups. It probably sounds crazy, but there’s actually two reasons for this: (1) the Solaris box isn’t in the same place as the Linux backup server, and (2) I need to backup my Linux files somewhere.

So, we’ll be first sync’ing all of our Solaris files over to the Linux box, and then asking for a copy of all the backups under Linux to also be on my Solaris RAID array. Simple.
[Read more...]