Table of Contents
During the first boot you have set up a basic system configuration. This chapter describes some common commands and operations.
At system startup the kernel displays a long sequence of messages
on the screen: these messages give information about the kernel
status (for example, available memory) and the peripherals that
have been detected on the system.
This information is very important for diagnosing hardware or
configuration problems, and for determining the name of the devices
for the peripherals (for example you can check if your network
card has been detected as
Usually these messages scroll on the screen too fast to be useful,
but you can use the dmesg(8) command to view them
dmesg | more
If something on your system doesn't appear to work correctly and
you ask for help on one of the NetBSD mailing lists, always remember
to include the relevant dmesg output in your post: it will help
other people diagnose your problem. Note that during the boot
process NetBSD also writes a copy of the
dmesg output to
This feature is useful because the system will scroll
“old” messages out of the dmesg buffer over
New users are often surprised by the fact that although the installation program recognized and mounted their CD-ROM perfectly, the installed system seems to have “forgotten” how to use the CD-ROM. There is no special magic for using a CD-ROM: you can mount it as any other file system, all you need to know is the device name and some options to the mount(8) command. You can find the device name with the aforementioned dmesg(8) command. For example, if dmesg(8) displays:
dmesg | grep ^cdcd0 at atapibus0 drive 1: <ASUS CD-S400/A, , V2.1H> type 5 cdrom removable
the device name is
cd0, and you can mount the
CD-ROM with the following commands:
mount -t cd9660 -o ro /dev/cd0a /cdrom
To make things easier, you can add a line to the
/dev/cd0a /cdrom cd9660 ro,noauto 0 0
Without the need to reboot, you can now mount the cdrom with:
When the cdrom is mounted you can't eject it manually; you'll have to unmount it before you can do that:
There is also a software command which unmounts the cdrom and ejects it:
To mount a floppy you must know the name of the floppy device and the file system type of the floppy. Read the fdc(4) manpage for more information about device naming, as this will differ depending on the exact size and kind of your floppy disk. For example, to read and write a floppy in MS-DOS format you use the following command:
mount -t msdos /dev/fd0a /mnt
/mnt, you can use another
directory of your choice; you could, for example, create a
/floppy directory like you did for the cdrom.
If you do a lot of work with MS-DOS floppies, you will want to
install the mtools package, which enables you to
access a MS-DOS floppy (or hard disk partition) without the need
to mount it.
It is very handy for quickly copying a file from/to
mcopy foo bar a:
mcopy a:baz.txt baz
mcopy a:\*.jpg .
If NetBSD shares the hard disk with MS-DOS or Windows, it is possible modify the disklabel and make the Windows partitions visible from NetBSD. First, you must determine the geometry of the Windows partition, for example using fdisk(8).
fdisk wd0NetBSD disklabel disk geometry: cylinders: 77520, heads: 16, sectors/track: 63 (1008 sectors/cylinder) ... Partition table: 0: OS/2 HPFS or NTFS or QNX2 or Advanced UNIX (sysid 7) bootmenu: WinXP start 63, size 20643462 (10080 MB, Cyls 0-1285), Active 1: NetBSD (sysid 169) start 20643525, size 57496635 (28075 MB, Cyls 1285-4864) 2: <UNUSED> 3: <UNUSED>
This example uses the
wd0 hard disk:
substitute the device for your hard disk.
The output of the fdisk command shows that the Windows partition uses NTFS (“OS/2 HPFS or NTFS or QNX2 or Advanced UNIX (sysid 7)”), if the partition was FAT it would have said “Primary 'big' DOS, 16-bit FAT (>32MB) (sysid 6)”.
The Windows partition is currently only known in the MBR partition table, in order to mount it from NetBSD it also needs to be in the NetBSD disk's disklabel. There are two ways to do so, editing the disklabel manually using disklabel -e, or using the mbrlabel(8) command, which is what we will describe first.
When running mbrlabel(8), it needs a disk which it will search for partitions that are in the MBR but not in the disklabel, and will then add them to the disklabel:
disklabel wd0... d: 78140160 0 unused 0 0 # (Cyl. 0 - 77519)
mbrlabel -rw wd0Found NTFS partition; size 20643462 (10079 MB), offset 63 adding NTFS partition to slot e. Found 4.2BSD partition; size 57496572 (28074 MB), offset 20643588 skipping existing unused partition at slot c. 16 partitions: # size offset fstype [fsize bsize cpg/sgs] a: 57236256 20643588 4.2BSD 1024 8192 46920 # (Cyl. 20479*- 77261*) b: 260316 77879844 swap # (Cyl. 77261*- 77519) c: 57496572 20643588 unused 0 0 # (Cyl. 20479*- 77519) d: 78140160 0 unused 0 0 # (Cyl. 0 - 77519) e: 20643462 63 NTFS # (Cyl. 0*- 20479*) Updating in-core and on-disk disk label.
disklabel wd0... d: 78140160 0 unused 0 0 # (Cyl. 0 - 77519) e: 20643462 63 NTFS # (Cyl. 0*- 20479*)
If you can't or don't want to use mbrlabel(8) for some
reason, you will have to edit the disklabel manually with data
from the fdisk-command above. The
partition with the NTFS filesystem begins at sector 63 and has a
size of 20643462 sectors. The NetBSD partition begins at sector
20643525 (20643525 = 20643462 + 63). You will use this data to
modify the BSD disklabel: all you have to do is add one line
which defines the position and type of the NTFS partition,
choosing one of the still unused partition id letters. Use the
disklabel command to modify the disklabel.
If you give the
-e option to
disklabel it will invoke your favourite
editor ($EDITOR) to modify the disklabel. For example:
disklabel -e wd0... # size offset fstype [fsize bsize cpg] ... d: 78140160 0 unused 0 0 # (Cyl. 0 - 77519) e: 20643462 63 NTFS
The partitions from “a” to “d” were already used, and the first available id was “e”. The “size” and “offset” fields have been filled with the previously calculated numbers. Next, the mount point must be created. For example:
finally, a line will be added to the
/dev/wd0e /c ntfs ro,noauto 1 3
If you want to mount a MS-DOS "FAT" partition instead of a NTFS
partition, use MSDOS as the "fstype" in the disklabel and
"msdos" as filesystem type (3rd column) in
/etc/fstab. You can also mount
FAT-filesystems read/write, i.e. you can use "rw" instead of
For details about NetBSD support for the MSDOS and NTFS
filesystems, see mount_msdos(8) and mount_ntfs(8).
Now the Windows partition can be mounted with a simple command:
With this method you can mount NFS, FAT and FAT32 partitions.
If you want to mount the partition(s) automatically at startup,
noauto option from
/dev/wd0e /c ntfs ro 1 3
It's time to add new users to the system, since you don't want to use the root account for your daily work (yes, we're serious about that!). NetBSD offers the useradd(8) utility to create user accounts. For example, to create a new user:
useradd -m joe
Accounts that can su(1) to root are required to be in the "wheel" group. This can be done when the account is created by specifying a secondary group:
useradd -m -G wheel joe
As an alternative, the usermod(8) command can be used to add a user to an existing group:
usermod -G wheel joe
In case you just created a user but forgot to set a password, you can still do that later using the passwd(1) command.
You can edit
/etc/group directly to add
users to groups, but do not edit
/etc/passwd directly! All
changes made to that file will get lost, see Section 5.6, “Shadow passwords”.
If the system uses ssh, direct root access via ssh is
disabled by default. Check the sshd_config(5) and
/etc/ssh/sshd_config to change this
Shadow passwords are enabled by default on NetBSD: all the
contain an “*”; the encrypted passwords are stored in
/etc/master.passwd, that can be read only by
When you start vipw(8) to edit the
password file, the program opens a copy of
/etc/master.passwd; when you exit,
vipw(8) checks the validity of the copy, creates a
/etc/passwd and installs the new
Finally, vipw(8) launches
pwd_mkdb(8), which creates the files
/etc/spwd.db, two databases which are equivalent to
/etc/master.passwd but faster to process.
As you can see, passwords are handled automatically by NetBSD; if you use vipw(8) to edit the password file you don't need any special administration procedure.
Use one of the following two shutdown(8) commands to halt and/or reboot the system:
shutdown -h now
shutdown -r now
Two other commands perform the same tasks are:
halt(8), reboot(8), and shutdown(8) are not synonyms: the latter is more sophisticated. On a multiuser system you should really use shutdown(8); this will allow you to schedule a shutdown time, notify users, and it will also take care to shutdown database processes etc. properly without simply kill(1)ing them. For a more detailed description, see the shutdown(8), halt(8) and reboot(8) manpages.