netbsd-tips

From NetBSD Wiki

Jump to: navigation, search

Contents

Happy 15th Birthday NetBSD!

This wiki page may be used to suggest, edit, and keep track of very short tips on using NetBSD. These tips may be used for a fortune(1) file containing NetBSD tips. (FreeBSD has a similar fortune database: "Useful hints, advice, and pointers to areas of the system that might not be apparent on first inspection.") Also if the quality of these tips are good enough, I may provide it in a free PDF book format download and have it printed as a book.

Please share brief tips, useful hints, simple command-line examples, suggestions, or simple advice for using NetBSD. (You may email reed if you prefer.)

As a 15th birthday celebration, let's attempt to gather at least 500 tips within one week (ending March 28).

This wikipage is organized in two parts: tips that need work (or suggestions for tips) and new tips (ready to add to the official netbsd-tips fortunes datfile). Tips will be removed from here once committed to NetBSD src.

Feel free to adjust the layout, design or use of this wikipage. Any suggestions for handling this would be appreciated.

Keep the tips short. Maybe keep to a maximum of six lines and 60 words. If your tip is longer than that, just post it elsewhere on this wiki site (as it is too long for a fortune).

Be sure to use terms/keywords that would be useful for searching the list when describing your tip.

Use the "%" (percent sign) on a line by itself to separate each tip.

Have fun reading and participating!


Ideas / Need work

In NetBSD /bin/sh is a version of ash. To enable it's line editing and tabcompletion for interactive usage, you can use:

set -o emacs
set -o tabcomplete

%

For user-mounted CDs.

/sbin/mount_cd9660 -o nosuid,nodev /dev/cd0a ${1:-$HOME/cd}
vfs.generic.usermount=1

%

New tips

To run a program on every login, put it into your .profile, but don't forget the sanity check before execution:

if [ -x /usr/games/fortune ]; then
        /usr/games/fortune
fi

%

You can extract your running kernel's configuration by invoking:

config -x /netbsd

%

NetBSD ships with the Korn Shell. To change your login shell to ksh, use:

chsh -s /bin/ksh

%

You can make your Caps Lock key act like an other Esc key (useful for vi and emacs), by adding the following to your xmodmap:

remove Lock = Caps_Lock
keysym Caps_Lock = Escape

%

When writing a shell script one often wants to display the script's filename without the path, for example to show it in the usage. The following expression will evaluate to it:

${0##*/}

%

You can force the users to change their password upon next login (useful after giving an account to someone):

usermod -F username

%

If you want to recursively grep for a file, you can use the GNU grep's "-r" option:

grep -r MAXPATHLEN /usr/include

or in a more standard, but also more complicated way:

find /usr/src/ -type f -print | xargs grep "NetBSD Foundation"

%

Are you looking for NetBSD documentation? Give a look to http://www.NetBSD.org/docs/ and to the NetBSD wikis: http://wiki.NetBSD.se/ (international), http://wiki.NetBSD.org.mx/ (mexican) and http://netbsdit.altervista.org/ (italian).

%

When tabbing for auto-completion in console, you will sometimes want to turn off this noisy bell. Depending on your current environment, the command to switch the bell off differs.

  • while in console mode (you need to be root to do this):
wsconsctl -w bell.pitch=0
  • under a pseudo-terminal in X:
xset b off

%

Many people think which(1) is the way to find out where an executable is located, but in fact the solution is shell-specific and which(1) is a csh utility. The correct way -- supported by most shells, including /bin/sh and GNU bash -- is command -v command. To make which DTRT in your shell, add an alias to your .profile:

alias which="command -v"

%

To make it easy to look up which country is represented by a DNS domain, I have /usr/local/bin/domain:

$ cat $(which domain)
#!/bin/sh
grep ^$1 /usr/share/misc/domains
$ domain ws  # for example
ws Western Samoa

%

Use the command progress(1) to monitor lengthy piped i/o operations.

$ progress -z -f bigarchive.tar.gz tar xf - # equivalent to "tar zxf bigarchive.tar.gz" with a progress meter
 40% |**********                       |   273 KB  271.95 KB/s    00:01 ETA

%

If you want to use find(1)/xargs(1) to work with files that have whitespaces in their names, use find(1)'s option "-print0", together with xargs(1)'s "-0" option. For example:

find $HOME -iname \*.mp3 -print0 | xargs -0 ls -l

%

A reasonably small bootable NetBSD partition in your pendrive may be a great tool for system recovery -- even for machines with other OSes!

%

Old Tips

Tips submitted to this wikipage that are committed to the official netbsd-tips fortunes datfile are removed from this wikipage. That is so it doesn't get confusing and unwieldy.

If you need to add a suggestion for an existing tip, feel free to make a note of it here.

Licensing

Let's just say this is in the public domain. Anything that is short enough for this is probably fair use. But don't take collections from others unless okay. If you want to attribute the tip to someone or something, go ahead.

Personal tools