dannyman.toldme.com

About Me : Free Style : Good Reads : News and Reaction : Photographs : Technical : Travels : Unsorted

Linux »

I see penguins.

Search:
August 24, 2008
Linux, Sundry, Technical, Testimonials

Linux Video “Blue Flesh” Bug

Link: http://dannyman.toldme.com/2008/08/24/ubuntu-nvidia-video-violet-hue/

This week I upgraded the guts in my desktop. For the video card I jumped up to an ASUS EN9600GT silent graphics card. It is pretty “bleeding edge” as far as Linux goes, and it is a double-wide card with a massive heatsink where others would have a fan. I like to reduce the white noise.

Unfortunately, it is too new for the currently-supported Ubuntu drivers. I used Ubuntu’s NvidiaManual docs to manually upgrade to the 173.14.12 drivers from NVidia’s site, and then things were happier. Except video playback. Files and DVDs seem to work okay, but the colors are off, notably, people get rendered with blue or purple flesh. (more…)

Feedback Welcome

July 4, 2008
Featured, FreeBSD, Linux, Mac OS X, Technical

HOWTO: Random Number in Shell Script

Link: http://dannyman.toldme.com/2008/07/04/shell-sh-bash-random-splay/

The other day I was working on a shell script to be run on several hundred machines at the same time. Since the script was going to download a file from a central server, and I did not want to overwhelm the central server with hundreds of simultaneous requests, I decided that I wanted to add a random wait time. But how do you conjure a random number within a specific range in a shell script?

Updated: Due to much feedback, I now know of three ways to do this . . .

1) On BSD systems, you can use jot(1):
sleep `jot -r 1 1 900`

2) If you are scripting with bash, you can use $RANDOM:
sleep `echo $RANDOM%900 | bc`

3) For portability, you can resort to my first solution:
# Sleep up to fifteen minutes
sleep `echo $$%900 | bc`

$$ is the process ID (PID), or “random seed” which on most systems is a value between 1 and 65,535. Fifteen minutes is 900 seconds. % is modulo, which is like division but it gives you the remainder. Thus, $$ % 900 will give you a result between 0 and 899. With bash, $RANDOM provides the same utility, except it is a different value whenever you reference it.

Updated yet again . . . says a friend:
nah it’s using `echo .. | bc` that bugs me, 2 fork+execs, let your shell do the math, it knows how
so $(( $$ % 900 )) should work in bsd sh

For efficiency, you could rewrite the latter two solutions:
2.1) sleep $(( $RANDOM % 900 ))
3.1) sleep $(( $$ % 900 ))

The revised solution will work in sh-derived shells: sh, bash, ksh. My original “portable” solution will also work if you’re scripting in csh or tcsh.

1 Comment

May 14, 2008
Linux, Technical

Canon i250 on Ubuntu 8.04

Link: http://dannyman.toldme.com/2008/05/14/canon-i250-hardy-heron/

The Ubuntu upgrade broke printing. Among other things, it removed my canoni250.ppd file. I struggled with it to no avail. Then I went back and pasted the commands in from last time and now it all works.

Yay.

1 Comment

May 6, 2008
FreeBSD, Linux, Mac OS X, Technical

Mini-HOWTO: What Time is UTC?

Link: http://dannyman.toldme.com/2008/05/06/what-time-utc/

I wanted to know what time it was in UTC, but I forgot my local offset. (It changes twice a year!) I figured I could look in the date man page, but I came up with an “easier” solution. Simply fudge the time zone and then ask.

0-20:57 djh@noneedto ~$ env TZ=UTC date
Tue May  6 03:57:07 UTC 2008

The env bit is not needed in bash, but it makes tcsh happy.

Update: Mark points out an easier solution:
date -u

Knowing you can set TZ= is still useful in case you ever need to contemplate an alternate timezone.

(Thanks, Saul and Dave for improving my knowledge.)

3 Comments

April 25, 2008
Linux, Technical, Technology, WordPress

WordPress 2.5.1

Link: http://dannyman.toldme.com/2008/04/25/wordpress-251/

There’s a notice on the WordPress dev blog that WordPress 2.5.1 is out. Alas, they neglected to link to the upgrade documentation. My favorite? Upgrading via Subversion:

0-11:17 djh@ratchet ~> cd public_html/toldme
0-11:17 djh@ratchet ~/public_html/toldme> svn sw http://svn.automattic.com/wordpress/tags/2.5.1/
[ . . . ]
Updated to revision 7839.

When I logged in to post this little note, it blocked me and ran the upgrade procedure, then I had to log in again, and here I am!

There’s a further note about the secret key setting:

Since 2.5 your wp-config.php file allows a new constant called SECRET_KEY which basically is meant to introduce a little permanent randomness into the cryptographic functions used for cookies in WordPress. You can visit this link we set up to get a unique secret key for your config file. (It’s unique and random on every page load.) Having this line in your config file helps secure your blog.

It leaves me to wonder: if the secret key can be randomly generated by a machine, why not go ahead and do that and then stash it in the database? There may be a good reason for that . . .

In unrelated news, I upgraded to the newer Ubuntu release at home yesterday. The only trick I have noticed so far is that it runs with Firefox 3.0, which is beta, and I lost use of my foxmarks plugin, for now. So, I’m waiting until that is supported before I upgrade my workstation.

Feedback Welcome

March 13, 2008
Linux, Technical

Canon i250 on Ubuntu 7.10

Link: http://dannyman.toldme.com/2008/03/13/canon-i250-ubuntu-feisty/

I had a rough go of it until I found BlackNight’s post, and now my Canon i250 printer works with Ubuntu like a charm. I thought I would recap here for those who, like me, at first Googled in vain. If you paste these command into Ubuntu 7.10 (Feisty) things ought to work:

First, enter your sudo password:

sudo echo

Now, this paste just might set up everything you need:

sudo apt-get install libpng3 libtiff4 cupsys alien
cd /tmp
wget http://download.canon.com.au/bj/i250linux/bjfilteri250-2.3-0.i386.rpm
wget http://download.canon.com.au/bj/i250linux/bjfiltercups-2.3-0.i386.rpm
sudo alien --scripts bjfilteri250-2.3-0.i386.rpm
sudo alien --scripts bjfiltercups-2.3-0.i386.rpm
sudo dpkg -i bjfiltercups_2.3-1_i386.deb bjfilteri250_2.3-1_i386.deb
sudo ln -s /usr/lib/libtiff.so.4 /usr/lib/libtiff.so.3
sudo ln -s /usr/lib/libpng.so.3 /usr/lib/libpng.so.2
sudo /etc/init.d/cupsys restart

Then, go set up your printer in the GUI, and specify this PPD file:

/usr/share/cups/model/canoni250.ppd

(Or, in retrospect, since it has a GNU license on it, you could just download the PPD directly off my web site.)

If things turn out less-than-straightforward, definitely review BlackNight’s page for details, and if this does work out for you drop him a thank you note in the comments!

Feedback Welcome

January 26, 2008
Featured, Free Style, FreeBSD, Linux, Mac OS X, Sundry, Technical, Technology

Trendspotting: “The Amiga Line”

Link: http://dannyman.toldme.com/2008/01/26/deader-than-amiga/

I have been playing with Google Trends, which will be happy to generate a pretty graph of keyword frequency over time. A rough gauge to the relative popularity of various things. This evening, I was riffing off a post from the Royal Pingdom, regarding the relative popularity of Ubuntu and Vista, among other things.

I got started graphing various Linux distributions against each other, XP versus Vista, and trying to figure out the best keyword for OS X. Then, I wondered about FreeBSD. Against Ubuntu, it was a flatline. So, I asked myself: what is the threshold for a dead or dying Operating System?

Amiga vs FreeBSD:
Google Trends: Amiga versus FreeBSD

Ouch! Can we get deader?

Amiga vs FreeBSD vs BeOS:
Google Trends: Amiga versus FreeBSD versus BeOS

To be fair, the cult of Amiga is still strong . . . BeOS is well and truly dead. But how do the BSDs fare?

Amiga vs FreeBSD vs BeOS vs NetBSD vs OpenBSD:
Google Trends: *BSD versus Amiga, BeOS

NetBSD has been sleeping with the BeOS fishes for a while, and OpenBSD is on its way. And that’s a league below Amiga!

In Red Hat land, only Fedora beats “the Amiga Line”. For Unix in general, nothing stops the Ubuntu juggernaut. But there’s a long way to go to catch up with Uncle Bill.

(Yes, it is a rainy night and the girlfriend is out of town.)

Postscript: Ubuntu versus Obama

3 Comments

January 11, 2008
About Me, FreeBSD, Linux, Mac OS X, Technical

SysAdmin OpEd: Where to Keep the Crons

Link: http://dannyman.toldme.com/2008/01/11/etc-crontab-or-die/

This is just a note which I contributed to a thread on sage-members, to get something off my chest, as to where people should maintain their crontab entries. I sincerely doubt that reading what I have to say will bring you any great illumination.

I’d say, any reasonable SysAdmin should default to /etc/crontab because every other reasonable SysAdmin already knows where it is. If anything is used in addition to /etc/crontab, leave a note in /etc/crontab advising the new guy who just got paged at 3:45am where else to look for crons.

For production systems, I strongly object to the use of per-user crontabs. I’m glad to hear I’m not alone. One thing I have to do in a new environment tends to be to write a script that will sniff out all the cron entries.

And then there was the shop that used /etc/crontab, user crons, and fcron to keep crons from running over each other. This frustrated me enough that I did a poor job of explaining that job concurrency could easily be ensured by executing a command through (something like) the lockf utility, instead of adding a new layer of system complexity.

Yes, I am a cranky old SysAdmin.

2 Comments

November 29, 2006
Linux, Technical

HOWTO: Audit User Crontabs

Link: http://dannyman.toldme.com/2006/11/29/crontab-l-u-star/

For production systems, I think it is best to use a single, centralized /etc/crontab, which simplifies the job of tracking batch processes. On a production system, batch scripts should be sufficiently robust such that if they are resource or lock-intensive, they make sure everything is okay before they get to work. Stuff like user crons and fcrontab can live in your development and corporate servers.

Of course, sometimes you inherit production systems with people who don’t think like you do. You’ll need to review what random user crons are running on each system. With any luck you’ll have a sane OS that keeps the user crontabs in a well-documented location. (FreeBSD? /var/cron/tabs . . . SuSE . . . still not sure . . .) Of course, luck is a fickle mistress, and sometimes you have to do it the evil way:

> cat /etc/passwd | awk -F : '{print "echo crontabs for user "$1"\ncrontab -l -u "$1"\n"}' > /tmp/crontabs.sh
> head /tmp/crontabs.sh
echo crontabs for user root
crontab -l -u root
 
echo crontabs for user bin
crontab -l -u bin
 
echo crontabs for user daemon
crontab -l -u daemon
 
echo crontabs for user lp
> sudo sh /tmp/crontabs.sh | mail -s "`hostname` crontabs" $USER

If you are borrowing my “recipe” you will likely want to put your e-mail address where it says $USER . . . and, you may have to do the same for fcron as well. Bah!

cat /etc/passwd | awk -F : '{print "echo fcrontabs for user "$1"\n/usr/local/bin/fcrontab -l -u "$1"\n"}' > /tmp/fcrontabs.sh
sudo sh /tmp/fcrontabs.sh | mail -s "`hostname` fcrontabs" $USER

Feedback Welcome

October 24, 2006
Linux, Technical

Linux HOWTO: Add Temporary File to Swap

Link: http://dannyman.toldme.com/2006/10/24/howto-swapon-file/

Scenario: a Linux system with two drives. The system was built with resiliency as a priority, but availability is not critical. So, the filesystems were mounted atop md raid1 for resiliency, and the swap was striped across an md raid0 for performance.

One disk failed and was removed from the system. System returns to service on remaining drive until RMA is completed. Users are informed that the system is available but does not have swap space. Consensus is reached to add some temporary swap space via a swapfile. (more…)

1 Comment

September 6, 2006
Linux, Technical, Technology

Serial Console Woes

Link: http://dannyman.toldme.com/2006/09/06/serial-console-woes/

So, I’m setting up a box. I need to test different filesystem configurations, which will involve a lot of boot-configure-install-post-install-benchmark cycles. We have a nice network boot infrastructure, but getting serial booting to work is always fun. Today I found that the vendor has set up BIOS “remote access” to COM2. Funny thing, the box only has one serial port! So, I set that to COM1, and configure console redirection only up to the boot loader, tell the bootloader that I want text console=ttyS0 and we’re in business!

But man, if SuSE’s YaST aint a bloody mess when it downgrades to text on a serial port:

yast

What you don’t see here is the constant slow screen-redraw, constant pressing control-L. This is what it looks like at a good moment!

I think I understand why. I mean, I would think that Linux developers would take serial consoles and text mode to heart. After all, that’s the whole point, right? But that’s how I think, because I manage dozens of servers at a time, remote, and all my boxes are rack-mount jobbies with lots o’ fans and nobody wants to be in the same room.

But the developers who hack on Linux probably aren’t hard-core SysAdmins. Their dev system is some beat-up old hardware sitting near their desk, wired up to a spare VGA monitor, so yeah, text mode is kind of an afterthought. Especially given the pain in the butt that setting up serial consoles can be!

Feedback Welcome

August 16, 2006
Linux, Technical

Linux Uptime Reset

Link: http://dannyman.toldme.com/2006/08/16/linux-uptime-reset/

dman: Anyone ever been on a Unix box and see uptime reset without a reboot?
SmooveB: dman: yes
David: dman: yes
***dman smiles
David: dman: my personal favorate is the rollover or the negative rollover
SmooveB: dman: linux in particular
dman: LINUX, you say?
David: SmooveB: fancy that, that’s where I’ve seen it too

It seems that this issue is near and dear to those involved in “the uptime project” where, I guess, geeks sit around comparing uptime size. Which is kind of juvenile. However, this bug gave me a hearty laugh:

How reproducible:
ALWAYS

Steps to Reproduce:
1. Boot Linux system
2. Go away for 497 days
3. check uptime

That would be a bitch to QA! (more…)

2 Comments

December 28, 2005
Linux, Technical, Technology, Testimonials

Red Hat Rant

Link: http://dannyman.toldme.com/2005/12/28/red-hat-rant/

Ahhh, so in my getting to grips with, I have a few gripes about Linux. Some day I may cultivate these into a well-formed, coherent technical explanation, but just now . . . just now, I’ll share with you a special favorite rant of mine.

New install, right? By default, it wants to check the install media (who cares?) then there’s a screen that says “welcome to <version of Red Hat>” where you get the chance to say “ohhh, wrong CD …” then you move on to disk partitioning, and you have to intentionally select that yes you want to erase all data, and enter a bunch of other parameters … network … firewall, SE-Linux … altogether 10-15 minutes if you know what you are doing. Nothing onerous. Lots of “yes, a firewall, and these other things, these are all a good ideas, I’ll just mostly agree to what you suggest.” (more…)

2 Comments

December 7, 2005
FreeBSD, Linux, Technical

pkgwhich == rpm -qf

Link: http://dannyman.toldme.com/2005/12/07/pkgwhich-rpm-qf/

Aye. So, let us say you want to know what package a file comes from.

On FreeBSD:

0-17:16 djh@web3 ~> find /var/db/pkg -name +CONTENTS | xargs grep -l pdftex
/var/db/pkg/teTeX-1.0.7_1/+CONTENTS

Ugly, eh? Which, I think the portinstall stuff has a pkgwhich command.

Linux?

[root@novadb0 pdftex-1.30.5]# rpm -qf /usr/bin/pdftex
tetex-2.0.2-22.EL4.4

Schweet!

3 Comments

November 16, 2005
Linux, Technical

Installing Software on FC4

Link: http://dannyman.toldme.com/2005/11/16/installing-software-on-fc4/

I’m new to Linux, but I’m trying out Fedora Core 4 on my work laptop. It’s pretty slick once you change the desktop environment to KDE. But I want to be able to play mp3s, and there’s nothing in the default system that can handle this, and yum doesn’t know where to find good stuff like mplayer or mpg123. (Yeah, I’m a command-line type of guy . . .)

So, I go shopping for “repositories” that extend the Fedora Core base repository . . . and the short answer is that if you do this: (more…)

3 Comments

Older Stuff »
Site Archive

Danny Howard is 100% responsible for the content on this site, except some of it is stolen.

All rights are reserved, unless otherwise noted. Generally, I'm a BSD guy, so you can assume implicit permission to adapt, modify, and redistribute my intellectual property with appropriate attribution. Except some of this content is itself re-appropriated, so you'd best ask first, especially for commercial use. Thanks!

You can contact me via e-mail: dannyman@toldme.com

Most of http://dannyman.toldme.com/ is powered by WordPress.

If you're hip to RSS and whatnot, you can subscribe to this site.

These links are for dannyman: login AND backlinks