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 ne0 or ne1.) Usually these messages scroll on the screen too fast to be useful, but you can use the dmesg command to view them again.
# 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.
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 command. You can find the device name with the aforementioned dmesg command. For example, if dmesg displays:
# dmesg | grep ^cd cd0 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:
# mkdir /cdrom # mount -t cd9660 -o ro /dev/cd0a /cdrom
in most cases NetBSD can also automatically detect the filesystem type. In most cases the following command is sufficient:
# mount /dev/cd0a /cdrom
To make things easier, you can add a line to the /etc/fstab file.
/dev/cd0a /cdrom cd9660 ro,noauto 0 0
Without the need to reboot, you can now mount the cdrom with:
# mount /cdrom
When the cdrom is mounted you can't eject it manually; you'll have to unmount it before you can do that:
# umount /cdrom
There is also a software command which unmounts the cdrom and ejects it:
# eject /dev/cd0a
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. For example, to read and write a floppy in MS-DOS format you use the following command:
# mount -t msdos /dev/fd0a /mnt
Instead of /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 floppy.
If NetBSD shares the hard disk with MS-DOS or Windows, it is possible modify the disklabel and make the DOS partitions visible from NetBSD. First, you must determine the geometry of the DOS partition , for example using fdisk.
# fdisk wd0 NetBSD disklabel disk geometry: cylinders: 6232 heads: 16 sectors/track: 63 (1008 sectors/cylinder) ... Partition table: 0: sysid 6 (Primary 'big' DOS, 16-bit FAT (> 32MB)) start 63, size 2088516 (1019 MB), flag 0x80 beg: cylinder 0, head 1, sector 1 end: cylinder 259, head 0, sector 4 1: sysid 169 (NetBSD) start 2088579, size 4193277 (2047 MB), flag 0x0 beg: cylinder 259, head 0, sector 4 end: cylinder 779, head 0, sector 1 2: <UNUSED> 3: <UNUSED>
Note: this example uses the wd0 hard disk: substitute the device for your hard disk.
The output of the fdisk command shows that the DOS partition begins at sector 63 and has a size of 2088516 sectors. The NetBSD partition begins at sector 2088579 (2088579 = 2088516 + 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 MS-DOS 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] ... e: 3450624 2831232 4.2BSD 1024 8192 16 # (Cyl. 2808* - 6231) f: 2088516 63 MSDOS
The partitions from "a" to "e" were already used by NetBSD and the first available id was "f". The "size" and "offset" fields have been filled with the previously calculated numbers. Next, the mount point must be created. For example:
# mkdir /msdos
finally, a line will be added to the /etc/fstab file.
/dev/wd0f /msdos msdos rw,noauto 1 3
Note: a disklabel can also be generated automatically using the mbrlabel command. Please read the mbrlabel(8) manpage for more information.
Now the MS-DOS partition can be mounted with a simple command:
# mount /msdos
With this method you can mount FAT and FAT32 partitions. If you want to mount the partition(s) automatically at startup, remove the "noauto" option from /etc/fstab.
/dev/wd0f /msdos msdos rw 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. NetBSD doesn't have a program to create new users; instead you should read the adduser manpage.
# man adduser
Following the instructions on the page you'll also begin using vipw which is the basic administration tool for new accounts under NetBSD.
Note: NetBSD 1.4.2 has a set of user administration tools; a useradd command and other commands too. For example, to create a new user:
# useradd -m joeThe defaults for the useradd command can be changed; see the useradd(8) man page.
If you have an earlier version of NetBSD and don't want to add new accounts manually you can install a package like, for example, addnerd from the packages collection. I suggest that you take a look at the man page and add at least one account manually, though.
Shadow passwords are enabled by default on NetBSD and can't be disabled: all the passwords in /etc/passwd contain an '*'; the encrypted passwords belong to another file, /etc/master.passwd, that can be read only by root. When you start vipw to edit the password file, the program opens a copy of /etc/master.passwd; when you exit, vipw checks the validity of the copy, creates a new /etc/passwd and installs a new /etc/master.passwd file. Finally, vipw launches pwd_mkdb, which creates the files /etc/pwd.db and /etc/spwd.db, two databases equivalent to /etc/passwd and /etc/master.passwd but faster to process.
As you can see, passwords are handled automatically by NetBSD; if you use vipw to edit the password file you don't need any special administration procedure.
It's very important to always use vipw and the other tools for account administration (chfn, chsh, chpass, passwd) and to never modify directly /etc/master.passwd.
The command used to halt and/or reboot the system is shutdown.
# shutdown -h now # shutdown -r now
Two other commands perform the same tasks:
# halt # reboot
halt/reboot and shutdown are not synonyms: the latter is more sophisticated. On a multiuser system you should really use shutdown: you can also schedule a shutdown, notify users, etc. For a more detailed description, see shutdown(8), halt(8) and reboot(8).