In part one, we introduced some basic commands to get you started with FreeBSD. In part two, we’ll explore some handy tricks to help you maneuver within the system and perform some useful administrative tasks.
When you’re stuck, use apropos or man -k
What if you know what you want to do, but you don’t have a clue which command to use? I like to use apropos, as it sounds so appropriate. However, if you struggle with spelling, man -k will give the same results. Let’s say you don’t know what command to use to change your password. Just type this:
apropos password

Every utility involving passwords will be listed, along with a brief description. A quick skim of the results, and I now know this:
passwd(1), yppasswd(1)
– modify a user’s password

If I haven’t used this command before, I’ll want to take a look at its man page:
man 1 passwd

I find it useful to leave the man page open in one terminal and try the command itself in another terminal. Using the virtual terminals is handy if the command has a list of switches. Also, always keep a notebook handy to record the command and the switches you used to accomplish a task. It sure beats wading through man pages a second time.

Use locate to find files
Whereis is great for finding applications, but you should use locate to find files. Let’s see why. If you type in
whatis whereis

you will get this reply:
whereis(1) – locate programs

However, if you type in
whatis locate

this reply will come back:
locate(1)- find filenames quickly
The first time you use the locate command, you will probably receive an error message stating that the database is too small. If you do not reboot your computer, the database will update itself once a week. If you don’t want to reboot now, you can update the database manually using this command:/usr/libexec/locate.updatedb
Be patient, as your hard drive will churn for a few minutes before you are returned to your prompt.
Now let’s find a file called fstab using the locate command:
locate fstab

Your reply might look like this:

History lesson
By now, you are probably tired of typing commands, so let’s use the history feature that comes with FreeBSD. If you type

you’ll see the command history of the virtual terminal you are in. Note that each command has a number in front of it. So, for example, if you type

the system will execute the command that has an 8 in front of it. This feature works for any numbered command in your history list. Also, typing

will repeat the last command you entered.

Shutting down
The last commands we will cover here deal with shutting down your FreeBSD box. Never just turn off a UNIX box. It will complain bitterly and remind you of your transgression the next time you reboot. There are several commands for gracefully shutting down a FreeBSD computer, but the two easiest to remember are reboot and halt.
If you want to reboot your computer, and you are not logged on as root, typingReboot
will result in this reply:reboot: Operation not permitted
Only root can shut down a UNIX computer, which is a good thing in a multiuser environment.
Open up another virtual terminal and log on as root:

Your computer will close all processes, then reboot. If you want to shut down your system completely, (as root) use halt instead:

After several seconds, you’ll receive a message that ends as follows:
The operating system has halted.
Please press any key to reboot.

It is now safe to power off your computer.
If you’d like to share your opinion, please post a comment at the bottom of this page or send the editor an e-mail.