Archive for category Linux Command of the Day

LCOD 11.14.07 – Quick RAID check script for cron

This is a quick script that will let you run the new raid checks, or repair, or pause a running raid check. It doesn’t do e-mails or anything, and from what I read on this thread it’s something mdadm needs to be set to watch for. I ran the check on a RAID and received no output, so I guess it was ok?

I will update the script as I find out more. I’d like to add a simple escalation from check to rebuild? (I think it does this anyways), and an e-mail status report, or even a syslog call saying I ran all things look good.


#!/bin/bash
###############
# Quick script to use raid functionality
# Author : Jon Zobrist < jon@bluesun.netThis e-mail address is being protected from spam bots, you need JavaScript enabled to view it >
# http://www.bluesun.net/
# License : LGPL
# Version : 1.0
# Date : 11.14.07
# install/notes:
# put it somewhere, /root/bin/ is where I prefer
# put this in your root crontab to run from cron monthly
# @monthly /root/bin/checkraids check > /root/logs/cron.log 2>&1
###############

case "$1" in
check)
for raid in /sys/block/md*/md/sync_action
do
echo check > $raid
done
;;

repair)
for raid in /sys/block/md*/md/sync_action
do
echo repair > $raid
done
;;

pause)
for raid in /sys/block/md*/md/sync_action
do
echo idle > $raid
done
;;

status)
for raid in /sys/block/md*/md/sync_action
do
echo "******************************"
echo $raid `cat $raid`
echo ""
done
;;

*)
echo "Usage : $0 check|repair|pause|status"
;;
esac

, , , , , ,

No Comments

LCOD – 11.9.07 – hald / wtf / .hal-mtab-lock

This isn’t really a Linux Command of the Day, and I’m not sure it really qualifies as a Linux tip…

I run Ubuntu desktop and really like it. At first I hated the auto plugin USB crap a lot of the
desktop distros were pushing, but once I started using it, and realized it actually worked
better than anything like it in the Windows world, and different but as good as the OS X world.

So, fast forward a year or so. All the sudden, certian devices won’t detect when I plug them in.
They *used* to work fine! All of the sudden they’re not auto-plugging or showing up in my nice GUI Nautilus interface.

I did a little looking around and noticed in /media there were 2 files, one was .hal-mtab, and one was .hal-mtab-lock.

The .hal-mtab looked like an mtab (tracks mounted file systems) file, and it had several devices of mine that had ceased to function properly. The .hal-mtab-lock file was weeks old.

I deleted the lines from the .hal-mtab, and deleted the .hal-mtab-lock file, rebooted and was good to go. Now my devices are working again.

I don’t know exactly what happened to cause this mess up, but my guess is something like the power went out and the devices were plugged in, or I unplugged and replugged them too many times in a row.

No Comments

LCOD – 9.20.07 – Palm Hardware: Windows Software: GoDaddy Cert.

While this isn’t actually a Linux tip, it’s for people who are savvy and buy $19/yr GoDaddy SSL Certificates instead of the $249/yr ones from Verisign.

Both do the SAME encryption, neither do much to actually verify you are who you claim.

So, you installed a GoDaddy SSL cert on your mail server, and your Windows on Palm users get certificate errors whenever they try to hit your webmail on SSL or normal mail on SSL.

The GoDaddy certificate repository, here has the root and intermediate certificates you need, but they’re in the wrong format!

You need to use OpenSSL to convert them.

I’ve converted them into DER already, the two you need for a new GoDaddy cert are here

http://subfund.submarinefund.com/gd_intermediate_bundle.cer

http://subfund.submarinefund.com/gd-class2-root.cer

Copy these to your desktop or laptop where you activesync to your Windows Palm phone.
Once they’re on your phone, simply click on them and it will prompt you to install them, say yes and you’ll be ready to go ssl!

enjoy

, ,

No Comments

LCOD – 7.28.07 – VMWare Server Howto on Ubuntu 7.0.4 Server

First of all, I used this VMware Howto to get started, and it works most of the time.
But, for some reason, sometimes my Ubuntu server installs with what seems like the same options
act differently. So this is a brief summary of the problems I’ve run into, and the solutions I’ve found.

First of all, the Ubuntu server install supports full software RAID. Software or hardware RAID
should always be run for redundancy on anything you’re going to call a server.

Now, this howto is simple and straight forward, the only place I found an infrequent problem is where
it says to say no and exit the installer without configuring, sometimes that doesn’t work. Finishing
the install until it crashes out saying it can’t install, I’ve found, and *then* running the any-any patch
seems to always work, so I recommend that.

http://www.howtoforge.com/ubuntu_feisty_fawn_vmware_server_howto

, , ,

No Comments

LCOD – 6.6.07 – Simple SSH remote command execution

ssh -X -C -f HOSTNAME PROGRAM

Of course you need to be running an X server (Linux/*BSD Desktop) on your client, and you need to have
ForwardX11 yes
or
ForwardX11Trusted yes

in your CLIENT’s /etc/ssh/ssh_config file
and
X11Forwarding yes
in /etc/ssh/sshd_config
on the SERVER.

, , , , ,

No Comments

LCOD – 5.9.07 – Updating CPAN in Perl

Perl rocks, it’s easily my favorite programming language. One of the nice things about Perl is the CPAN (Comprehensive Perl Archive Network). Your Linux box has CPAN installed already, and to begin using it you should first update it. To do so run the commands just below. The first time you invoke CPAN it’ll launch the configuration module, just hit enter until it gets into the part about which mirrors you want to use, it’ll have you pick geographic areas first, and then tell you to enter servers by number, separated by spaces. I usually put in about 20 servers, which looks like kinda this

30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10

#invoke perl’s CPAN shell (and first time configuration with)
bash$ perl -MCPAN -e shell
#once configuration is done, update CPAN, and then reload
CPAN> install Bundle::CPAN
CPAN> reload cpan

Now, head on over to CPAN and search for some cool new Perl modules to play with!

A great place to dive into the world of Perl is Perl.org

Also the Perl Monks is a good Perl site, and Use Perl is as well.

Make sure you have a correct build environment setup, on Ubuntu/Debian you need to install the build-essential package (sudo apt-get install build-essential)

, , , ,

No Comments

LCOD – 5.9.07 – Find out what Perl DBI drivers are installed

A perl one liner for you.

Say you’re installing something that is DBI and it’s giving errors or having problems,

or anything, and you want to know if it’s because you don’t have the correct perl DBI

driver installed? This is a simple, one liner, which will tell you a list of all the perl DBI drivers.

Run from the command line

perl -e ‘use DBI;@driver_names = DBI->available_drivers; print “@driver_names\n”;’

You should get output like

DBM ExampleP File Proxy SQLite2 Sponge mysql

enjoy

, , ,

No Comments

LCOD – 5.6.07 – Recovering pictures from flash disks

Ever have a corrupted flash memory card? Plug it into Linux and you’ll see tons of FAT corrupt or unreadable errors in dmesg output. Plug it into Windows and you’ll see a ton of files and folders with crazy corrupt names.

First thing you do, whenever you’re faced with any type of file recovery situation, is STOP USING THE DISK! Do not write ANYTHING to the disk.

Then, install PhotoRec (In Ubuntu 7.0.4 I ran, apt-get install testdisk).

http://www.cgsecurity.org/wiki/PhotoRec

I won’t attempt to write better PhotoRec instructions than you’ll find here

http://www.pcstats.com/articleview.cfm?articleid=1869&page=6

I used this recently on 2 8GB cards each with about 600 pictures in Canon RAW format, and it seems to have recovered all of them, except 1 which seems to be corrupt. Compared to the 160 or so that showed up in Windows, this is really a life saver.

, , , , ,

No Comments

LCOD – 3.19.07 – finding shared folders in vmware

Not sure where to find files in your Linux vmware host when you’ve shared them as a vmware shared folder?

“In a Linux virtual machine, shared folders appear under /mnt/hgfs. So the shared folder in this example would appear as /mnt/hgfs/Test files.”

So if you share it as drive I it will show up as /mnt/hgfs/drive I
Which you would need to access with a \ to escape out that space in the path…

cd /mnt/hgfs/drive\ I

I finally found this info here, after searching all over…

http://www.vmware.com/support/ws45/doc/running_sharefold_ws.html

, ,

No Comments

LCOD – 3.12.07 – Speeding up your DNS queries

I did some testing and OpenDNS is fast.

To change to use OpenDNS instead of your own, or worse! your ISP’s crappy, poorly maintained dns server, you can follow the instructions here.

http://opendns.com/start/

The basic info is to put in these 2 IP’s as your dns servers

208.67.222.222
208.67.220.220

On Linux/*BSD you’d put them in your /etc/resolv.conf file like this

nameserver 208.67.222.222
nameserver 208.67.220.220

If you’d like to double whammy your performance run a local cache, I use DJB’s djbdns dnscache in forwarding only mode, as described here.

http://cr.yp.to/djbdns/run-cache-x-home.html

With the above IP’s in the @ file.

Installing DJB’s stuff is cake, you can pretty much cut & paste his instructions found here

http://cr.yp.to/djbdns/install.html

Of course you’ll need Daemontools, and ucspi, install instructions (cut & pasteable) here

http://cr.yp.to/daemontools/install.html
http://cr.yp.to/ucspi-tcp/install.html

If you get compilation errors cuz DJB hasn’t fixed a bug in his code and some systems (lots of recent Linux systems), run these commands.
(run after you’ve extracted the archive, and cd’d into it’s directory, and run for EACH install.) You may get a no such file for the src one on some, but he mixes software locations, so just run em both.

perl -pi -e ‘s/extern int errno\;/\#include <errno.h>/’ *
perl -pi -e ‘s/extern int errno\;/\#include <errno.h>/’ src/*

Enjoy!

, , , ,

No Comments