FreeBSD: 102 Tips and Tricks

FreeBSD Tip: #31

"man ports" gives many useful hints about installing FreeBSD ports.

FreeBSD Tip: #32

"man security" gives very good advice on how to tune the security of your
FreeBSD system.

FreeBSD Tip: #33

"man tuning" gives some tips how to tune performance of your FreeBSD system.
		-- David Scheidt <dscheidt at tumbolia.com>

FreeBSD Tip: #34

Need to do a search in a manpage or in a file you've sent to a pager? Use
"/search_word". To repeat the same search, type "n" for next.
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #35

Need to find the location of a program? Use "locate program_name".
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #36

Need to leave your terminal for a few minutes and don't want to logout?
Use "lock -p". When you return, use your password as the key to unlock the
terminal.
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #37

Need to print a manpage? Use

	man name_of_manpage | col -bx | lpr
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #38

Need to quickly empty a file? Use ": > filename".
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #39

Need to quickly return to your home directory? Type "cd".
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #40

Need to remove all those ^M characters from a DOS file? Try

	tr -d \r < dosfile > newfile
		-- Originally by Dru <genesis at istar.ca>

FreeBSD Tip: #41

Need to see the calendar for this month? Simply type "cal".  To see the
whole year, type "cal -y".
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #42

Need to see which daemons are listening for connection requests? Use
"sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6.
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #43

Need to see your routing table? Type "netstat -rn". The entry with the G
flag is your gateway.
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #44

Nice bash prompt: PS1='([$(tput md)]t <w>[$(tput me)]) $(echo $?) $ '
		-- Mathieu <mathieu at hal.interactionvirtuelle.com>

FreeBSD Tip: #45

Over quota?  "du -s * | sort -n " will give you a sorted list of your
directory sizes.
		-- David Scheidt <dscheidt at tumbolia.com>

FreeBSD Tip: #46

nc(1) (or netcat) is useful not only for redirecting input/output to
TCP or UDP connections, but also for proxying them with inetd(8).

FreeBSD Tip: #47

sh (the default Bourne shell in FreeBSD) supports command-line editing.  Just
``set -o emacs'' or ``set -o vi'' to enable it.

FreeBSD Tip: #48

Simple tcsh prompt: set prompt = '%# '

FreeBSD Tip: #49

The default editor in FreeBSD is vi, which is efficient to use when you have
learned it, but somewhat user-unfriendly.  To use ee (an easier but less
powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee

FreeBSD Tip: #50

Time to change your password? Type "passwd" and follow the prompts.
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #51

To change an environment variable in /bin/sh use:

	$ VARIABLE="value"
	$ export VARIABLE

FreeBSD Tip: #52

To change an environment variable in tcsh you use: setenv NAME "value"
where NAME is the name of the variable and "value" its new value.

FreeBSD Tip: #53

To clear the screen, use "clear". To re-display your screen buffer, press
the scroll lock key and use your page up button. When you're finished,
press the scroll lock key again to get your prompt back.
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #54

To determine whether a file is a text file, executable, or some other type
of file, use

	file filename
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #55

To do a fast search for a file, try

	 locate filename

locate uses a database that is updated every Saturday (assuming your computer
is running FreeBSD at the time) to quickly find files based on name only.

FreeBSD Tip: #56

To erase a line you've written at the command prompt, use "Ctrl-U".
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #57

To find out the hostname associated with an IP address, use

	dig -x IP_address
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #58

To obtain a neat PostScript rendering of a manual page, use ``-t'' switch
of the man(1) utility: ``man -t <topic>''.  For example:

	man -t grep > grep.ps	# Save the PostScript version to a file
or
	man -t printf | lp	# Send the PostScript directly to printer

FreeBSD Tip: #59

To quickly create an empty file, use "touch filename".
		-- Dru <genesis at istar.ca>

FreeBSD Tip: #60

To read a compressed file without having to first uncompress it, use
"zcat" or "zless" to view it.
		-- Dru <genesis at istar.ca>

You may also like...