Chapter 9. System Administration

9.1. Where are the system start-up configuration files?
9.2. How do I add a user easily?
9.3. Why do I keep getting messages like root: not found after editing /etc/crontab
9.4. Why do I get the error, you are not in the correct group to su root when I try to su to root?
9.5. I made a mistake in rc.conf, or another startup file, and now I cannot edit it because the file system is read-only. What should I do?
9.6. Why am I having trouble setting up my printer?
9.7. How can I correct the keyboard mappings for my system?
9.8. Why can I not get user quotas to work properly?
9.9. Does FreeBSD support System V IPC primitives?
9.10. What other mail-server software can I use instead of sendmail?
9.11. I have forgotten the root password! What do I do?
9.12. How do I keep Control+Alt+Delete from rebooting the system?
9.13. How do I reformat DOS text files to UNIX® ones?
9.14. How do I kill processes by name?
9.15. How do I re-read /etc/rc.conf and re-start /etc/rc without a reboot?
9.16. I tried to update my system to the latest -STABLE, but got -BETAx, -RC or -PRERELEASE! What is going on?
9.17. I tried to install a new kernel, and the chflags(1) failed. How do I get around this?
9.18. I cannot change the time on my system by more than one second! How do I get around this?
9.19. Why is rpc.statd using 256 MB of memory?
9.20. Why can I not unset the schg file flag?
9.21. Why does SSH authentication through .shosts not work by default in recent versions of FreeBSD?
9.22. What is vnlru?
9.23. What do the various memory states displayed by top mean?
9.24. How much free memory is available?
9.25. What is /var/empty? I can not delete it!
9.26. I just changed /etc/newsyslog.conf. How can I check if it does what I expect?
9.27. My time is wrong, how can I change the timezone?

9.1.

Where are the system start-up configuration files?

The primary configuration file is /etc/defaults/rc.conf (see rc.conf(5)). System startup scripts such as /etc/rc and /etc/rc.d (see rc(8)) just include this file. Do not edit this file! Instead, if there is any entry in /etc/defaults/rc.conf that you want to change, you should copy the line into /etc/rc.conf and change it there.

For example, if you wish to start named(8), the included DNS server, all you need to do is:

# echo 'named_enable="YES"' >> /etc/rc.conf

To start up local services, place shell scripts in the /usr/local/etc/rc.d directory. These shell scripts should be set executable, the default file mode is 555.

9.2.

How do I add a user easily?

Use the adduser(8) command, or the pw(8) command for more complicated situations.

To remove the user, use the rmuser(8) command or, if necessary, pw(8).

9.3.

Why do I keep getting messages like root: not found after editing /etc/crontab

This is normally caused by editing the system crontab (/etc/crontab) and then using crontab(1) to install it:

# crontab /etc/crontab

This is not the correct way to do things. The system crontab has a different format to the per-user crontabs which crontab(1) updates (the crontab(5) manual page explains the differences in more detail).

If this is what you did, the extra crontab is simply a copy of /etc/crontab in the wrong format it. Delete it with the command:

# crontab -r

Next time, when you edit /etc/crontab, you should not do anything to inform cron(8) of the changes, since it will notice them automatically.

If you want something to be run once per day, week, or month, it is probably better to add shell scripts /usr/local/etc/periodic, and let the periodic(8) command run from the system cron schedule it with the other periodic system tasks.

The actual reason for the error is that the system crontab has an extra field, specifying which user to run the command as. In the default system crontab provided with FreeBSD, this is root for all entries. When this crontab is used as the root user's crontab (which is not the same as the system crontab), cron(8) assumes the string root is the first word of the command to execute, but no such command exists.

9.4.

Why do I get the error, you are not in the correct group to su root when I try to su to root?

This is a security feature. To su to root (or any other account with superuser privileges), you must be in the wheel group. If this feature were not there, anybody with an account on a system who also found out root's password would be able to gain superuser level access to the system. With this feature, this is not strictly true; su(1) will prevent them from even trying to enter the password if they are not in wheel.

To allow someone to su to root, simply put them in the wheel group. Use pw(8) for this purpose.

# pw groupmod wheel -m lisa

The above example will add user lisa to the group wheel.

9.5.

I made a mistake in rc.conf, or another startup file, and now I cannot edit it because the file system is read-only. What should I do?

Restart the system using boot -s at the loader prompt to enter Single User mode. When prompted for a shell pathname, simply press Enter, and run mount -urw / to re-mount the root file system in read/write mode. You may also need to run mount -a -t ufs to mount the file system where your favorite editor is defined. If your favorite editor is on a network file system, you will need to either configure the network manually before you can mount network file systems, or use an editor which resides on a local file system, such as ed(1).

If you intend to use a full screen editor such as vi(1) or emacs(1), you may also need to run export TERM=xterm on FreeBSD 9.0+, or export TERM=cons25 on FreeBSD 8.X so that these editors can load the correct data from the termcap(5) database.

Once you have performed these steps, you can edit /etc/rc.conf as you usually would to fix the syntax error. The error message displayed immediately after the kernel boot messages should tell you the number of the line in the file which is at fault.

9.6.

Why am I having trouble setting up my printer?

See the Handbook entry on printing. It should cover most of your problem.

Some printers require a host-based driver to do any kind of printing. These so-called WinPrinters are not natively supported by FreeBSD. If your printer does not work in DOS or Windows®, it is probably a WinPrinter. Your only hope of getting one of these to work is to check if the print/pnm2ppa port supports it.

9.7.

How can I correct the keyboard mappings for my system?

Please see the Handbook section on using localization, specifically the section on console setup.

9.8.

Why can I not get user quotas to work properly?

  1. It is possible that your kernel is not configured to use quotas. If this is the case, you will need to add the following line to your kernel configuration file and recompile:

    options QUOTA

    Please read the Handbook entry on quotas for full details.

  2. Do not turn on quotas on /.

  3. Put the quota file on the file system that the quotas are to be enforced on, i.e.:

    File SystemQuota file
    /usr/usr/admin/quotas
    /home/home/admin/quotas

9.9.

Does FreeBSD support System V IPC primitives?

Yes, FreeBSD supports System V-style IPC, including shared memory, messages and semaphores, in the GENERIC kernel. With a custom kernel, support may be loaded with the sysvshm.ko, sysvsem.ko and sysvmsg.ko kernel modules, or enabled in the custom kernel by adding the following lines to your kernel config:

options    SYSVSHM          # enable shared memory
options    SYSVSEM          # enable for semaphores
options    SYSVMSG          # enable for messaging

Recompile and install your kernel.

9.10.

What other mail-server software can I use instead of sendmail?

The sendmail server is the default mail-server software for FreeBSD, but you can easily replace it with one of the other MTA (for instance, an MTA installed from the ports).

There are various alternative MTAs in the ports tree already, with mail/exim, mail/postfix, mail/qmail, and mail/zmailer being some of the most popular choices.

Diversity is nice, and the fact that you have many different mail-servers to chose from is considered a good thing; therefore try to avoid asking questions like Is sendmail better than qmail? in the mailing lists. If you do feel like asking, first check the mailing list archives. The advantages and disadvantages of each and every one of the available MTAs have already been discussed a few times.

9.11.

I have forgotten the root password! What do I do?

Do not panic! Restart the system, type boot -s at the Boot: prompt to enter Single User mode. At the question about the shell to use, hit Enter. You will be dropped to a # prompt. Enter mount -urw / to remount your root file system read/write, then run mount -a to remount all the file systems. Run passwd root to change the root password then run exit(1) to continue booting.

Note:

If you are still prompted to give the root password when entering the Single User mode, it means that the console has been marked as insecure in /etc/ttys. In this case it will be required to boot from a FreeBSD installation disk, choose the Live CD or Shell at the beginning of the install process and issue the commands mentioned above. You will need to mount the specific partition in this case and then chroot to it, i.e., replace mount -urw / by mount /dev/ada0p1 /mnt; chroot /mnt for a system on ada0p1.

Note:

If you cannot mount your root partition from Single User mode, it is possible that the partitions are encrypted and it is impossible to mount them without the access keys. Your chances depend on the chosen implementation. For more information see the section about encrypted disks in the FreeBSD Handbook.

9.12.

How do I keep Control+Alt+Delete from rebooting the system?

If you are using syscons(4) (the default console driver) build and install a new kernel with the line in the configuration file:

options SC_DISABLE_REBOOT

This can also be done by setting the following sysctl(8) which does not require a reboot or kernel recompile:

# sysctl hw.syscons.kbd_reboot=0

Note:

The above two methods are exclusive: The sysctl(8) does not exist if you compile your kernel with the SC_DISABLE_REBOOT option.

9.13.

How do I reformat DOS text files to UNIX® ones?

Use this perl(1) command:

% perl -i.bak -npe 's/\r\n/\n/g' file(s)

where file(s) is one or more files to process. The modification is done in-place, with the original file stored with a .bak extension.

Alternatively you can use the tr(1) command:

% tr -d '\r' < dos-text-file > unix-file

dos-text-file is the file containing DOS text while unix-file will contain the converted output. This can be quite a bit faster than using perl.

Yet another way to reformat DOS text files is to use the converters/dosunix port from the Ports Collection. Consult its documentation about the details.

9.14.

How do I kill processes by name?

Use pkill(1).

9.15.

How do I re-read /etc/rc.conf and re-start /etc/rc without a reboot?

Go into single user mode and then back to multi user mode.

On the console do:

# shutdown now
(Note: without -r or -h)

# return
# exit

9.16.

I tried to update my system to the latest -STABLE, but got -BETAx, -RC or -PRERELEASE! What is going on?

Short answer: it is just a name. RC stands for Release Candidate. It signifies that a release is imminent. In FreeBSD, -PRERELEASE is typically synonymous with the code freeze before a release. (For some releases, the -BETA label was used in the same way as -PRERELEASE.)

Long answer: FreeBSD derives its releases from one of two places. Major, dot-zero, releases, such as 9.0-RELEASE are branched from the head of the development stream, commonly referred to as -CURRENT. Minor releases, such as 6.3-RELEASE or 5.2-RELEASE, have been snapshots of the active -STABLE branch. Starting with 4.3-RELEASE, each release also now has its own branch which can be tracked by people requiring an extremely conservative rate of development (typically only security advisories).

When a release is about to be made, the branch from which it will be derived from has to undergo a certain process. Part of this process is a code freeze. When a code freeze is initiated, the name of the branch is changed to reflect that it is about to become a release. For example, if the branch used to be called 6.2-STABLE, its name will be changed to 6.3-PRERELEASE to signify the code freeze and signify that extra pre-release testing should be happening. Bug fixes can still be committed to be part of the release. When the source code is in shape for the release the name will be changed to 6.3-RC to signify that a release is about to be made from it. Once in the RC stage, only the most critical bugs found can be fixed. Once the release (6.3-RELEASE in this example) and release branch have been made, the branch will be renamed to 6.3-STABLE.

For more information on version numbers and the various Subversion branches, refer to the Release Engineering article.

9.17.

I tried to install a new kernel, and the chflags(1) failed. How do I get around this?

Short answer: You are probably at security level greater than 0. Reboot directly to Single User mode to install the kernel.

Long answer: FreeBSD disallows changing system flags at security levels greater than 0. You can check your security level with the command:

# sysctl kern.securelevel

You cannot lower the security level; you have to boot to Single Mode to install the kernel, or change the security level in /etc/rc.conf then reboot. See the init(8) manual page for details on securelevel, and see /etc/defaults/rc.conf and the rc.conf(5) manual page for more information on rc.conf.

9.18.

I cannot change the time on my system by more than one second! How do I get around this?

Short answer: You are probably at security level greater than 1. Reboot directly to Single User mode to change the date.

Long answer: FreeBSD disallows changing the time by more that one second at security levels greater than 1. You can check your security level with the command:

# sysctl kern.securelevel

You cannot lower the security level; you have to boot to Single User mode to change the date, or change the security level in /etc/rc.conf then reboot. See the init(8) manual page for details on securelevel, and see /etc/defaults/rc.conf and the rc.conf(5) manual page for more information on rc.conf.

9.19.

Why is rpc.statd using 256 MB of memory?

No, there is no memory leak, and it is not using 256 MB of memory. For convenience, rpc.statd maps an obscene amount of memory into its address space. There is nothing terribly wrong with this from a technical standpoint; it just throws off things like top(1) and ps(1).

rpc.statd(8) maps its status file (resident on /var) into its address space; to save worrying about remapping it later when it needs to grow, it maps it with a generous size. This is very evident from the source code, where one can see that the length argument to mmap(2) is 0x10000000, or one sixteenth of the address space on an IA32, or exactly 256 MB.

9.20.

Why can I not unset the schg file flag?

You are running at an elevated (i.e., greater than 0) securelevel. Lower the securelevel and try again. For more information, see the FAQ entry on securelevel and the init(8) manual page.

9.21.

Why does SSH authentication through .shosts not work by default in recent versions of FreeBSD?

The reason why .shosts authentication does not work by default in more recent versions of FreeBSD is because ssh(1) is not installed suid root by default. To fix this, you can do one of the following:

  • As a permanent fix, set ENABLE_SUID_SSH to true in /etc/make.conf then rebuild and reinstall ssh(1).

  • As a temporary fix, change the mode on /usr/bin/ssh to 4555 by running chmod 4555 /usr/bin/ssh as root.

9.22.

What is vnlru?

vnlru flushes and frees vnodes when the system hits the kern.maxvnodes limit. This kernel thread sits mostly idle, and only activates if you have a huge amount of RAM and are accessing tens of thousands of tiny files.

9.23.

What do the various memory states displayed by top mean?

  • Active: pages recently statistically used.

  • Inactive: pages recently statistically unused.

  • Cache: (most often) pages that have percolated from inactive to a status where they maintain their data, but can often be immediately reused (either with their old association, or reused with a new association). There can be certain immediate transitions from active to cache state if the page is known to be clean (unmodified), but that transition is a matter of policy, depending upon the algorithm choice of the VM system maintainer.

  • Free: pages without data content, and can be immediately used in certain circumstances where cache pages might be ineligible. Free pages can be reused at interrupt or process state.

  • Wired: pages that are fixed into memory, usually for kernel purposes, but also sometimes for special use in processes.

Pages are most often written to disk (sort of a VM sync) when they are in the inactive state, but active pages can also be synced. This depends upon the CPU tracking of the modified bit being available, and in certain situations there can be an advantage for a block of VM pages to be synced, whether they are active or inactive. In most common cases, it is best to think of the inactive queue to be a queue of relatively unused pages that might or might not be in the process of being written to disk. Cached pages are already synced, not mapped, but available for immediate process use with their old association or with a new association. Free pages are available at interrupt level, but cached or free pages can be used at process state for reuse. Cache pages are not adequately locked to be available at interrupt level.

There are some other flags (e.g., busy flag or busy count) that might modify some of the described rules.

9.24.

How much free memory is available?

There are a couple of kinds of free memory. One kind is the amount of memory immediately available without paging anything else out. That is approximately the size of cache queue + size of free queue (with a derating factor, depending upon system tuning). Another kind of free memory is the total amount of VM space. That can be complex, but is dependent upon the amount of swap space and memory. Other kinds of free memory descriptions are also possible, but it is relatively useless to define these, but rather it is important to make sure that the paging rate is kept low, and to avoid running out of swap space.

9.25.

What is /var/empty? I can not delete it!

/var/empty is a directory that the sshd(8) program uses when performing privilege separation. The /var/empty directory is empty, owned by root and has the schg flag set.

Although it is not recommended to delete this directory, to do so you will need to unset the schg flag first. See the chflags(1) manual page for more information (and bear in mind the answer to the question on unsetting the schg flag).

9.26.

I just changed /etc/newsyslog.conf. How can I check if it does what I expect?

To see what newsyslog(8) will do use the following:

% newsyslog -nrvv

9.27.

My time is wrong, how can I change the timezone?

Use tzsetup(8).

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.