FreeBSD: 102 Tips and Tricks

These tips will look familiar to any one who has games/fortune in their MOTD, because indeed this is where they’re from. These tips are well worth reading, even for an experienced FreeBSD user. For example, how many users know about the “look” command, I for one am enlightened!

FreeBSD Tip: #1

Any user that is a member of the wheel group can use "su -" to simulate
a root login. You can add a user to the wheel group by editing /etc/group.
		-- Konstantinos Konstantinidis <kkonstan at>

FreeBSD Tip: #2

By pressing "Scroll Lock" you can use the arrow keys to scroll backward
through the console output.  Press "Scroll Lock" again to turn it off.

FreeBSD Tip: #3

Can't remember if you've installed a certain port or not? Try "pkg_info
-Ix port_name".

FreeBSD Tip: #4

Ever wonder what those numbers after command names were, as in cat(1)?  It's
the section of the manual the man page is in.  "man man" will tell you more.
		-- David Scheidt <dscheidt at>

FreeBSD Tip: #5

Forget how to spell a word or a variation of a word? Use

	look portion_of_word_you_know
		-- Dru <genesis at>

FreeBSD Tip: #6

Forget what directory you are in? Type "pwd".
		-- Dru <genesis at>

FreeBSD Tip: #7

Forget when Easter is? Try "ncal -e". If you need the date for Orthodox
Easter, use "ncal -o" instead.
		-- Dru <genesis at>

FreeBSD Tip: #8

FreeBSD is started up by the program 'init'.  The first thing init does when
starting multiuser mode (ie, starting the computer up for normal use) is to
run the shell script /etc/rc.  By reading /etc/rc and the /etc/rc.d/ scripts,
you can learn a lot about how the system is put together, which again will
make you more confident about what happens when you do something with it.

FreeBSD Tip: #9

Handy bash(1) prompt:  PS1="u at h w !$ "
		-- David Scheidt <dscheidt at>

FreeBSD Tip: #10

Having trouble using fetch through a firewall? Try setting the environment
variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.

FreeBSD Tip: #11

If other operating systems have damaged your Master Boot Record, you can
reinstall it either with /usr/sbin/sysinstall or with boot0cfg(8). See
"man boot0cfg" for details.

FreeBSD Tip: #12

If you accidentally end up inside vi, you can quit it by pressing Escape, colon
(:), q (q), bang (!) and pressing return.

FreeBSD Tip: #13

If you are in the C shell and have just installed a new program, you won't
be able to run it unless you first type "rehash".
		-- Dru <genesis at>

FreeBSD Tip: #14

If you do not want to get beeps in X11 (X Windows), you can turn them off with

	xset b off

FreeBSD Tip: #15

If you have a CD-ROM drive in your machine, you can make the CD-ROM that is
presently inserted available by typing 'mount /cdrom' as root.  The CD-ROM
will be available under /cdrom/.  Remember to do 'umount /cdrom' before
removing the CD-ROM (it will usually not be possible to remove the CD-ROM
without doing this.)

Note: This tip may not work in all configurations.

FreeBSD Tip: #16

If you need a reminder to leave your terminal, type "leave +hhmm" where
"hhmm" represents in how many hours and minutes you need to leave.
		-- Dru <genesis at>

FreeBSD Tip: #17

If you need to ask a question on the FreeBSD-questions mailing list then

contains lots of useful advice to help you get the best results.

FreeBSD Tip: #18

If you write part of a filename in tcsh,
pressing TAB will show you the available choices when there
is more than one, or complete the filename if there's only one match.

FreeBSD Tip: #19

If you `set watch = (0 any any)' in tcsh, you will be notified when
someone logs in or out of your system.

FreeBSD Tip: #20

If you use the C shell, add the following line to the .cshrc file in your
home directory to prevent core files from being written to disk:

	limit coredumpsize 0
		-- Dru <genesis at>

FreeBSD Tip: #21

If you want df(1) and other commands to display disk sizes in
kilobytes instead of 512-byte blocks, set BLOCKSIZE in your
environment to 'K'.  You can also use 'M' for Megabytes or 'G' for
Gigabytes.  If you want df(1) to automatically select the best size
then use 'df -h'.

FreeBSD Tip: #22

If you want to play CDs with FreeBSD, a utility for this is already included.
Type 'cdcontrol' then 'help' to learn more.  (You may need to set the CDROM
environment variable in order to make cdcontrol want to start.)

FreeBSD Tip: #23

If you want to quickly check for duplicate package/port installations,
try the following pkg_info command.

	pkg_info | sort | sed -e 's/-[0-9].*$//' | 
	uniq -c | grep -v '^[[:space:]]*1'

FreeBSD Tip: #24

If you'd like to keep track of applications in the FreeBSD ports tree, take a
look at FreshPorts;

FreeBSD Tip: #25

In order to make fetch (the FreeBSD downloading tool) ask for
username/password when it encounters a password-protected web page, you can set
the environment variable HTTP_AUTH to 'basic:*'.

FreeBSD Tip: #26

In order to search for a string in some files, use 'grep' like this:

	 grep "string" filename1 [filename2 filename3 ...]

This will print out the lines in the files that contain the string.  grep can
also do a lot more advanced searches - type 'man grep' for details.

FreeBSD Tip: #27

In order to support national characters for European languages in tools like
less without creating other nationalisation aspects, set the environment
variable LC_ALL to 'en_US.ISO8859-1'.

FreeBSD Tip: #28

"man firewall" will give advice for building a FreeBSD firewall
		-- David Scheidt <dscheidt at>

FreeBSD Tip: #29

"man hier" will explain the way FreeBSD filesystems are normally laid out.
		-- David Scheidt <dscheidt at>

FreeBSD Tip: #30

Man pages are divided into section depending on topic.  There are 9 different
sections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual).
You can get an introduction to each topic by typing

	man <number> intro

In other words, to get the intro to general commands, type

	man 1 intro

You may also like...