dannyman.toldme.com

Search:

FreeBSD, Linux, Sundry, Technical, WordPress

FAQ: Why is SSH into my server so slow?!

Link: http://dannyman.toldme.com/2010/06/05/fix-your-dns-with-google/

I have run in to this a zillion times. You SSH to a Unix server, type your password, and then wait a minute or two before you get the initial shell prompt, after which everything is reasonably zippy.

The short answer is “probably, something is wrong with DNS . . . your server is trying to look up your client but it can not, so it sits there for a couple of minutes until it times out, and then it lets you in.”

Yesterday I was working with an artist who had a hosting account, and when he got in, I said:

sudo vim /etc/resolv.conf

He admitted that he had just copied the DNS configuration from his previous server. How to fix this? Well, he could check what nameservers are provided by his current hosting company . . . . or, I changed his file to read:

nameserver 8.8.8.8

“What’s that, localhost?”

“It’s Google! Wherever you are, they’ll give you DNS.”

“Cool!!”

“Yes!!”

Feedback Welcome


Linux, Sundry, Technical

HOWTO: Add a Swapfile at Boot

Link: http://dannyman.toldme.com/2010/05/28/ubuntu-linux-add-swap-file-at-boot/

A while back I outfitted my personal workstation with 4GB of RAM. That’s plenty of memory and since disk space was tight I didn’t want to waste any on a swap partition, and I lived happily without swap for a very long time until I began using more virtualization. (I freed up space on my physical desk top by migrating my work environment from a laptop to a virtual machine on my personal workstation.)

I wrote a script to add a “temporary” swap file on demand but what I wanted was a swap file at boot. That actually turns out to be pretty simple. In this case, I just prepare the swap file:

FILE=/mnt/swapfile
SIZE=8388608 # 8 GB

dd if=/dev/zero of=$FILE bs=1024 count=$SIZE
mkswap $FILE $SIZE
swapon $FILE
swapon -s

Then, to make it stick, add this line to /etc/fstab just as you would for a swap partition:

/mnt/swapfile none swap sw 0 0

This is a win for the Unix everything-is-a-file philosophy.

See Also: Ubuntu Community Swap FAQ

3 Comments


Linux, Sundry, Technical, WordPress

Rackspace Cloud Server: Crude Performance Tuning

Link: http://dannyman.toldme.com/2010/05/20/rackspace-cloud-server-crude-performance-tuning/

I recently migrated this web site to a virtual server at the Rackspace Cloud. I started with the cheapest, 256M slice, but after hitting some performance issues really quickly, I figured that the extra $10/month to grow the slice to 512M was worthwhile. Even so, I don’t think MySQL and Apache are tuned, out-of-the-box, for such “small” systems.

I am running WordPress, a PHP application, on Apache and MySQL, running on CentOS. I am using Munin to track the system health. Since MySQL performance tuning can be extremely complicated I have focussed my initial efforts on Apache.

So, the memory graph would ideally top out at 512MB, but in practice, the system and programs allocate excess memory they rarely touch, and that gets paged out to swap. It is when the swap activity gets high that system performance goes to heck. A spike in system load is a good symptom of possible performance issues.


When things went bad on Wednesday, I tuned Apache down somewhat from the defaults and then enabled the Apache status page, and told Munin to go ahead and graph that. I am new to Munin, but Slicehost has some excellent articles on installing and configuring it in my environment.

This morning Munin sent me e-mail that it was having trouble collecting data, so I took a look, and reset performance values for Apache based on the above graph:

<IfModule prefork.c>
StartServers      6
MinSpareServers   3
MaxSpareServers  12
ServerLimit      15
MaxClients       15
MaxRequestsPerChild  4000
</IfModule>

Hopefully, this will hold. I would love to audit the system memory use in greater detail to allow Apache some greater flexibility, but in the interests of achieving a stable system quickly, this will hopefully prove to be a good strategy.

Feedback Welcome


Linux, Technical

Ubuntu: Re-install All Packages

Link: http://dannyman.toldme.com/2010/05/05/ubuntu-reinstall-all-packages/

After some transient disk issues I was stuck with an Ubuntu VMWare image that was brain dead. I figured I would give the install CD a chance to fix but the Ubuntu install CD doesn’t have a fix-it option. (Really?!) Since the issue was somewhere in how Gnome and X were configured, I launched an xterm session and managed this command:

dpkg --get-selections \* | awk '{print $1}' | xargs -l1 aptitude reinstall

What that does is get a list of all packages installed on a system, then invoke “reinstall” for each package. It took a few hours to run.

The Ubuntu forums had a recipe using some more straightforward Debian incantation, but that didn’t work for me.

Feedback Welcome


Linux, Sundry, Technical, Technology

Windows 7 vs Ubuntu 9.10

Link: http://dannyman.toldme.com/2009/12/02/windows-7-ubuntu-first-impression/

So, I tried Windows 7 beta, and recently scored a copy of Windows 7 for my desktop PC, via employee discount. (I’d be willing to pay $50 for the OS, so $25 isn’t a bad deal. The again, Microsoft sent me some very large checks for my Tellme equity in 2007 so a very small Capitalist part of me is rooting for them.)

Where do you want to install Windows?

It is pretty nice: basically a refresh of Windows XP, with extra spit-and-polish. Zippier, too! It boots and shuts down faster than XP or Ubuntu, and manages OS updates without requiring my intervention and subsequently breaking things, like Ubuntu does. I was musing to my coworkers that if it had the following, I could switch from Linux:

1) A decent software packaging system.
2) Built-in Virtual Desktops.
3) Middle-button paste.

Boot/Shutdown Speed

I turn my computers off when I’m not using them. I like that Firefox will remember tab sessions. But waiting for an OS to boot is wasted time.

Despite recent improvements, Ubuntu still takes way too long to boot, and seemingly forever to shut down. Windows 7, by contrast, is pretty darn zippy. I like that!

Winner: Windows 7

System Updates

So, for the record, I’m thinking to turn off system updates on my Ubuntu environments, because they aren’t worth it and they keep breaking my stuff. I’ll just refresh twice a year when the new release comes out, therefor managing the pain of upgrades. Windows updates are more important, given the constant security threats. Fortunately, Windows does that for me without my noticing, save the stupid “I will forcibly reboot you in 5 minutes” thing that hasn’t hit me (yet?) on Windows 7.

Winner: Windows 7

Software Packaging

Windows seems to have made some improvements with software packaging, and I gotta say it is convenient to go to a web site, click on an installer, and a few minutes later have the application running. Of course, then there’s another icon on your desktop and the Yahoo! tool bar has been added to your web browser . . .

On Ubuntu, though, most of the time I go to a shell and type:

sudo aptitude install foo

And there I go!

Sometimes software isn’t available in the central repositories, but 9.10 has made adding some PPAs easier. And sometimes I go to a web site, click on a link to a .deb file, it downloads, the system asks for my password, and the software gets installed without leaving crappy toolbars in my environment. Victory!

Winner: Ubuntu

Virtual Desktops

Ubuntu’s Gnome interface would be nicer if I could drag windows to the side of the screen and they’d pop over to the next screen, like the fvwm2 pager. But, I’m pretty well content with Ubuntu’s virtual desktop ability.

You could probably install a decent hack on Windows 7 to get this, but really, virtual desktops and pagers should be built in.

Winner: Ubuntu

Command Line Environment

So, with Ubuntu I can fire off command shells with wild abandon and do what I need to do. (I’m a Unix system administrator, so I relate to computers mostly by typing commands and scripting.) Windows 7 has a new “PowerShell” feature that implements a few Unix commands. After half an hour of searching I discovered that you can get to the PowerShell by hitting Windows+R and then typing “powershell” — heck forbid we should put this in the start menu or make it available by searching for “shell” but okay . . .

With Ubuntu, I can highlight text by dragging and clicking my mouse. This is just like other environments, but instead of hitting control-C (or, ahem Open-Apple-C) to copy the highlighted text into your clipboard, and control-V (I mean, Command-V) to paste from your clipboard, with Unix, whatever you highlight goes straight to the clipboard, and you paste by tapping the middle mouse button.

That can be a little scary sometimes but once you get used to the convenience you really can’t go back to having to mouse and keyboard to cut and paste.

Once you figure out how to launch the PowerShell, you can not simply highlight text with the mouse. Seriously, WTF!? No, this is how you copy-and-paste stuff with PowerShell:

Hit Alt+Space to bring up the console menu, then type ‘E’ to bring up the ‘Edit’ menu and then ‘k’ to start copying or ‘P’ to paste the text in the clipboard to the console. In ‘copying’ mode, you just use the arrow keys while holding down the shift key to select text, and hit Enter to add the selection to the clipboard.

Durr
“Ah, hello, Microsoft? Yes, the 1980s called and they want their primitive user interface back. Thanks!”

Update: You can launch PowerShell is a window that supports text highlighting by dragging the mouse via Start > All Programs > Windows PowerShell > Windows PowerShell. It looks like you can copy highlighted text with control+C and paste with the right mouse button. (Getting closer, I guess!)

Winner: Ubuntu

Focus Follow Mouse

Down in the accessibility menu, there’s an option for “Activate a window by hovering over it with a mouse” . . . but checking that option doesn’t actually change the behavior . . .

. . . correction: it does. After some seconds it brings the window you are hovering over to front. No, I just want focus, not raise! Arrr! Ubuntu knows how to do this, with just a little checkbox.

Update: There are three ways to do this. The registry hack was my solution.

Winner: Ubuntu

Default Web Browser

I’ll give Internet Explorer some credit; I can type whatever crazy thing I want into the URL bar and the second it realizes I didn’t type a URL, it goes over to Bing. Nice!

But then the default behavior is to create new windows all over. Seriously: what is the point of tabbed browsing if you don’t put stuff in the tabs? The big fail though is that for whatever reason the WordPress HTML editor in Explorer keeps jumping up to the top of the text input window, which made working out this post a seriously annoying experience.

A quick install of Google Chrome and my web browsing experience not only interfaces well with WordPress and pops new windows into tabs, but I can type whatever crazy stuff I want into the URL bar and in a not-be-evil sort of way, it shunts me with due humility over to Bing. So, Chrome is my new default web browser for Windows 7. (And I’ll continue trying out Bing, even though I’m a Google fan-boy.)

Winner: Ubuntu

5 Comments


Linux

HOWTO: Ubuntu Support for Audio in XVidCap

Link: http://dannyman.toldme.com/2009/09/28/howto-ubuntu-xvidcap-audio-support/

XVidCap is a very nice screen-capture program for Linux.  I have been dabbling in it to capture video of my desktop.

Unfortunately, the binary offered by Ubuntu’s software distribution has audio disabled. I found a bug about that somewhere and added my two cents, then went and installed it manually. Then I had to reinstall it manually because the Ubuntu version had been bumped and the “newer” version replaced my audio-supporting version.

Step 1: Remove Existing xvidcap

sudo aptitude remove xvidcap

Step 2: Install XVidCap from SourceForge

http://sourceforge.net/projects/xvidcap/ — click “download now” and the rest is all point-and-click.

Step 3: Lock XVidCap Version

Ubuntu will be quietly bide its time until it can “upgrade” xvidcap to a version that doesn’t support Audio. Fortunately, you can tell it not to do that!

Open: System > Administration > Synaptic Package Manager

Search for “xvidcap”

Select the package, go to the Package menu and select “Lock Version”

(From what I can tell, sudo aptitude hold won’t actually prevent xvidcap from being “upgraded.”)

3 Comments


Linux, Technical

Ubuntu: Turn off Periodic FSCK

Link: http://dannyman.toldme.com/2008/11/19/e2fsck-frog-off/

I halt my computer at night, and boot it in the morning. This reduces my carbon impact. Alas, Ubuntu for whatever brain-dead reason doesn’t trust its filesystem. As if we lived in the 1970s it insists on checking the filesystem consistency every thirtieth boot. I sip my morning coffee, check my workstation, and have to hit ESC . . .

So, I googled a bit, and found a helpful forum thread. I thought I’d offer my own tiny variation:

0-09:57 dannhowa@T60p ~$ sudo tune2fs -c 0 `mount | awk '$3 == "/" {print $1}'`
tune2fs 1.40.8 (13-Mar-2008)
Setting maximal mount count to -1

Update: wamukota made an excellent suggestion, that one can instead set an interval with the -i flag. For example, one could set their computer to check every three months:

0-19:06 djh@noneedto ~$ sudo tune2fs -i 3m `mount | awk '$3 == "/" {print $1}'`
tune2fs 1.41.4 (27-Jan-2009)
Setting interval between checks to 7776000 seconds

Okay, that is a scary-looking command-line. Let me break it down. (more…)

1 Comment


About Me, Featured, Linux, News and Reaction, Technical, Technology, Testimonials

New York Times Reviews G1

Link: http://dannyman.toldme.com/2008/10/17/new-york-times-reviews-g1/

I should receive my first new mobile phone since 2004 on October 22. I don’t really need a new phone: the old Sidekick 2 is built like a tank and shows no sign of giving up the ghost any time soon. But I went and pre-ordered a G1 for three reasons:
1) I have a friend on Google’s Android team.
2) To annoy the iPhone weenies.
3) My employer made its targets, so I spend a little of my bonus check.

I haven’t actually used one yet, so I was pleased to catch a review in the New York Times. Some of what I enjoyed:

One crucial improvement over the iPhone: a Menu button. It summons a panel of big buttons for functions related to what you’re doing. It’s the equivalent of right-clicking a computer mouse.

“Right mouse button!” HA!

Where Android really falls down is in the iPod department. There’s no companion program like iTunes to sync your photos, music and videos to the phone; you’re expected to drag these items to the phone manually after connecting via USB cable to your Mac or PC. More time-consuming fussiness.

This is a win for me: I hate iTunes. Dragging and dropping files is just the ticket, in my book. I’ve been dealing with that interface metaphor for fifteen years and its more comfortable than dealing with the quirks of some new software package. (Back when I had lots of issues with iTunes doing stuff like copying my library over twice.) That, and I run Linux desktops.

Some of the goodies in Android will reward the iPhone holdouts: voice dialing, picture messaging, built-in audio recording and the ability to turn any song into a ring tone are all included — no charge.

Voice dialing? That should be nice. And audio recording might be fun, too. Too bad the camera is supposedly crap, and no video. But that’s why I have my Canon.

The big news is the physical keyboard. It’s not pure joy, though. The keys don’t click down much. Worse, you have to keep turning the phone 90 degrees from its customary vertical orientation every time you need to enter text. That gets old fast. And it’s bizarre that, even though the phone contains a tilt sensor like the iPhone’s, it’s not hooked up to the screen. Turning the phone 90 degrees to get a wider look at a photo or Web page doesn’t rotate the image. You have to do that manually, using a menu or by popping open the keyboard, which makes no sense.

The keyboard is my biggest concern. I think the Sidekick 2 keyboard is nearly ideal and it is a big reason I shun the iPhone. Software bugs (sounds like the e-mail client is a mess) can be addressed by future patches or possibly third-party applications. I like to think rotation can be sorted out down the road.

Overall, it sounds like the G1 will be the dowdier, more adaptable PC to the flashy smugness that is the iPhone. And, I have to admit, while I love the turtleneck sweater I bought in France, I am a PC guy. (I think that’s the point of the new Microsoft ads: Bill Gates is as big a schmuck as Jerry Seinfeld or any one else.)

Lastly, this is just sad:

Finally, there’s no headphone jack. (Hello?!) If you want to use headphones, you have to buy and carry a special adapter that connects to the USB jack.

Feedback Welcome


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…)

2 Comments


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


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.

2 Comments


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


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


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!

4 Comments


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

Older Stuff »
Site Archive