Learning NetBSD: Shell Customization
Posted on July 7th, 2005
After successfully installing NetBSD on an old Powermac, I got started right away on doing nothing with it. But after a brief hiatus, I'm finally getting a chance to start exploring the brave new BSD world. First stop: a friendlier shell.
Right after I did the initial install, the first thing I did was
figure out how to install Emacs. Seeing as how that was a while back
and all, the process didn't quite burn iteslf into my mind. So when I
discovered that the standard shell I use with Linux
wasn't already available in NetBSD by default (reading man chsh mentions
the file /etc/shells, which is a list of available shells
on your system), I had to reintroduce myself to
pkg_add.
From the limited bit of reading around I've done, the luxury of choosing between source-based software installs that you compile yourself and precompiled software installs is an important concept for the new user to understand. For me, not so much; on old hardware with limited disk space I'll just stick with the path of least compiling, thanks. It's similar to the approach that you use with Debian-- sure you can compile stuff on your own, but it's so much more convenient to take what's already there.
In NetBSD, pkg_add is to Debian's apt-get install, and
pkg_delete is to dpkg --purge. The command
apropos comes in handy here-- it told me about pkg_info,
which when run as root lists all your installed packages much like
apt-show-versions.
So I knew I wanted to install bash, and I knew I didn't want to compile myself. Off to NetBSD's software directory, browsable by name or category. Under the shells category I found the bash-3.0pl16nb1 package easily enough, and so I installed it like so:
metroplex: {1} pkg_add ftp://ftp.netbsd.org/.../bash-3.0pl16.tgz
ftp: connect to address 2001:4f8:4:7:2e0:81ff:fe21:6563: No route to
host
pkg_add: Package
`ftp://ftp.netbsd.org/.../bash-3.0pl16.tgz'
OS mismatch:
pkg_add: NetBSD/powerpc 2.0_STABLE (pkg) vs. NetBSD/powerpc 2.0.2
(this host)
===> Updating /etc/shells
I think I can guess about that no-route message; need to see about turning off IPV6 support. But the OS mismatch thing, that was unexpected. I guess it's NetBSD noticing that I'm installing a package that belongs to a previous release, and warning me. Probably need to look into that as well-- is this the sort of behavior that you just ignore, or should it be shut off/shut up somehow.
Another surprise was the location of bash following the package
installation-- not under /bin/bash as with Linux, but
/usr/pkg/bin/bash. So all my shell scripts that have
#!/bin/bash on their first line really ought to be more
cross-platform and use #!/usr/bin/env bash instead. On the
plus side, now that NetBSD is in the picture I actually have a reason
to use /usr/bin/env other than "it's the right thing to do."
I also installed misc/gnuls in order to get a version of ls that could support color. Evidently the ls that comes with NetBSD doesn't do that? Weird.
That's about it for this session. I'm still a good bit away from actually doing anything interesting with NetBSD, but at least I've got some equivalence on the command line with the Linux environment I'm already used to. And I think I've got the basics of pre-compiled package installation down, not that it was especially complicated.