Linux

Breaking Bad Habits - Don't Use seq in Your Shell Scripts

Like most, I learned shell scripting by following examples. Well, unfortunately, most of the samples I learned from used the 'seq' binary to execute a simple for loop like so:

for i in `seq 1 10`; do
echo $i
done

I discovered why this is bad today - not all Unixes (Solaris and Darwin included) come with it. Not to mention we're forking a process where we don't need it. On bash, use the built-in brace expansion instead:

for i in {1..10}; do
echo $i
done
0
Your rating: None

The Nagios Fork: Did Two Wrongs Make a Right???

It's an item that I feel hasn't got much press, at least in the limited RSS entries I've had time to scan lately: Nagios has been forked. I've been using Nagios long enough that I actually used NetSaint for a bit, so I have some mixed feelings about Icinga. In general, I'm all for forks when they are indeed needed - FOSWiki is a great example. But forks shouldn't be taken lightly, in many ways they are like a divorce - they should be a last resort, not a quick way out. Personally, I think that the fork will ultimately either fail or merge back into Nagios, but read on for why I think the Icinga fork is a case of two wrongs making a right.

0
Your rating: None

Stupid SSH Tricks: Run Java GUI's on a Solaris 10 headless host with output on a Linux host

Running GUI's over an SSH tunnel is nothing new, and not too tricky. However, I recently had a case where I wanted to run a java-based GUI (dhcpmgr) as root on a remote host, and have it display on my local Linux box. I hit a couple of snags, so I thought I'd post them here to hopefully help out others.

0
Your rating: None

Doing Simple Source Policy Routing on CentOS

I'm not for sure when they did it, but the RHEL folks made it a bunch easier to setup simple source policy routing. By using source policy routing, we fix the issue of firewalls freaking out when the reply packet to a host leaves a multihomed host on a different interface than what the request came in on. In prior versions, you had to setup some custom scripts, but that's no longer the case - all the hooks are there in the OS now.

0
Your rating: None

Restoring GRUB after Windows Blows It Away

If you make the mistake of installing Windows after Linux, it will rewrite your MBR, killing GRUB. Some might argue simply installing Windows on your computer is a mistake, but let's fix the MBR and worry about that later. ;-)

0
Your rating: None

List installed packages in Ubuntu

I found this over at the Ubuntu Forums, but since it took me forever to find, I'm dropping notes here.

In RPM-based distros, you can do 'rpm -qa > somefile.txt'. In Debian/Ubuntu, do this:

dpkg --get-selections > machineA.txt

In true apt fashion, if you then want to have machine B have all the software machine A has, do this:

dpkg --set-selections < machineA.txt && dselect

Enjoy!

0
Your rating: None

Use NetworkManager to launch scripts based on Network Location

NetworkManager is fast becoming the de facto network provider in desktop Linux distributions. The reason it's so popular is that it "does the right thing" 99% of the time. However, there's not many examples out there that extend that functionality. NetworkManager provides hooks in which you can have scripts launch when network settings change. In today's post, I will show you how to launch the Synergy client whenever you plug into your corporate network.

5
Your rating: None Average: 5 (1 vote)

Use LVM on an installation of Ubuntu

RHEL/CentOS has had support for LVM in setup for quite some time now, but for whatever reason, Ubuntu has been slow at adopting support for LVM at installation. Usually, I just grumble and move on with ext3 -- not today. Convinced that I couldn't be the only person wanting LVM support, I set out to do just that. Luckily, it wasn't hard at all!

5
Your rating: None Average: 5 (1 vote)

Create CD's from FLAC files with mp3cd

So, you store all your CD's as FLAC, and encode FLAC to MP3 on the fly. Now, you've gone and lost that CD, or in my case, your 3 year old daughter loses it for you. How do you regenerate a CD from your FLAC's?

mp3cd does just that. I was all set to code something up myself, but mp3cd is currently maintained, and even available in the Ubuntu repositories! It has a man page, and it even works -- why reinvent the wheel?

0
Your rating: None

Estimate time-to-completion with est

Like many of you other sysadmins, I run a lot of ad-hoc, long running jobs. Also like many of you, I have a full plate and can't stand to sit around watching things run. Often times, I will start such a job and forget to come back to it until the end of the day. I needed a way to find out quickly about how long these tasks would take to run so that I could make a mental note or set a reminder to check the task later.

0
Your rating: None
Syndicate content