*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  FreeBSD Tips              
Tip: 1      Comments: 62
Having trouble using fetch through a firewall? Try setting the environment
variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
Tip: 2      Comments: 1
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.
Tip: 3      Comments: 1
Want colour in your directory listings?  Use "ls -G".  "ls -F" is also useful,
and they can be combined as "ls -FG".
Tip: 4      Comments: 2632
If you need to ask a question on the FreeBSD-questions mailing list then

	http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\
		freebsd-questions/index.html

contains lots of useful advice to help you get the best results.
Tip: 5      Comments: 84
If you'd like to keep track of applications in the FreeBSD ports tree, take a
look at FreshPorts;

	http://www.freshports.org/
Tip: 6      Comments: 2
To search for files that match a particular name, use find(1); for example

	find / -name "*GENERIC*" -ls

will search '/', and all subdirectories, for files with 'GENERIC' in the name.
      	--  Stephen Hilton 
Tip: 7      Comments: 135
In tcsh, you can `set autolist' to have the shell automatically show
all the possible matches when doing filename/directory expansion.
Tip: 8      Comments: 926
You can `set autologout = 30' to have tcsh log you off automatically
if you leave the shell idle for more than 30 minutes.
Tip: 9      Comments: 0
If you `set filec' (file completion) in tcsh and write a part of the
filename, pressing TAB will show you the available choices when there
is more than one, or complete the filename if there's only one match.
Tip: 10      Comments: 96
You can press up-arrow or down-arrow to walk through a list of
previous commands in tcsh.
Tip: 11      Comments: 0
You can disable tcsh's terminal beep if you `set nobeep'.
Tip: 12      Comments: 0
If you `set watch = (0 any any)' in tcsh, you will be notified when
someone logs in or out of your system.
Tip: 13      Comments: 1
Nice tcsh prompt: set prompt = '%m %# '
Tip: 14      Comments: 1
Nice tcsh prompt: set prompt = '%n@%m%# '
Tip: 15      Comments: 1
Nice tcsh prompt: set prompt = '%n@%m:%~%# '
Tip: 16      Comments: 0
Nice tcsh prompt: set prompt = '%n@%m:%/%# '
Tip: 17      Comments: 0
Nice tcsh prompt: set prompt = '[%B%m%b] %B%~%b%# '
Tip: 18      Comments: 0
Simple tcsh prompt: set prompt = '%# '
Tip: 19      Comments: 0
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'.
Tip: 20      Comments: 0
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.
Tip: 21      Comments: 0
To change an environment variable in /bin/sh use:

	$ VARIABLE="value"
	$ export VARIABLE
Tip: 22      Comments: 0
You can use /etc/make.conf to control the options used to compile software
on this system.  Example entries are in
/usr/share/examples/etc/defaults/make.conf.
Tip: 23      Comments: 0
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.
Tip: 24      Comments: 0
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.
Tip: 25      Comments: 0
You can use the 'fetch' command to retrieve files over ftp or http.

	 fetch http://www.freebsd.org/index.html

will download the front page of the FreeBSD web site.
Tip: 26      Comments: 0
In order to make fetch (the FreeBSD downloading tool) ask for
username/password when it encounter a password-protected web page, you can set
the environment variable HTTP_AUTH to 'basic:*'.
Tip: 27      Comments: 0
You can permanently set environment variables for your shell by putting them
in a startup file for the shell.  The name of the startup file varies
depending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use
.profile.  When using bash, sh, ksh or zsh, don't forget to export the
variable.
Tip: 28      Comments: 0
If you are running xterm, the default TERM variable will be 'xterm'.  If you
set this environment variable to 'xterm-color' instead, a lot of programs will
use colors.  You can do this by

	TERM=xterm-color; export TERM

in Bourne-derived shells, and

	setenv TERM xterm-color

in csh-derived shells.
Tip: 29      Comments: 0
If you do not want to get beeps in X11 (X Windows), you can turn them off with

	xset b off
Tip: 30      Comments: 0
You can look through a file in a nice text-based interface by typing

	less filename
Tip: 31      Comments: 0
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
Tip: 32      Comments: 0
If you accidently end up inside vi, you can quit it by pressing Escape, colon
(:), q (q), bang (!) and pressing return.
Tip: 33      Comments: 0
You can use aliases to decrease the amount of typing you need to do to get
commands you commonly use.  Examples of fairly popular aliases include (in
bourne shell style, as in /bin/sh, bash, ksh, and zsh):

	alias lf="ls -FA"
	alias ll="ls -lA"
	alias su="su -m"

In csh or tcsh, these would be

	alias lf ls -FA
	alias ll ls -lA
	alias su su -m

To remove an alias, you can usually use 'unalias aliasname'.  To list all
aliases, you can usually type just 'alias'.
Tip: 34      Comments: 0
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'.
Tip: 35      Comments: 0
You can search for documentation on a keyword by typing

	apropos keyword
Tip: 36      Comments: 0
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  intro

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

	man 1 intro
Tip: 37      Comments: 0
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, 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.
Tip: 38      Comments: 0
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.)
Tip: 39      Comments: 1
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.
Tip: 40      Comments: 0
You can install extra packages for FreeBSD by using the ports system.
If you have installed it, you can download, compile, and install software by
just typing

	# cd /usr/ports//
	# make install && make clean

as root.   The ports infrastructure will download the software, change it so
it works on FreeBSD, compile it, install it, register the installation so it
will be possible to automatically uninstall it, and clean out the temporary
working space it used.  You can remove an installed port you decide you do not
want after all by typing

	# cd /usr/ports//
	# make deinstall

as root.
Tip: 41      Comments: 0
Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
		-- Mathieu 
Tip: 42      Comments: 0
To see the output from when your computer started, run dmesg(8).  If it has
been replaced with other messages, look at /var/run/dmesg.boot.
		-- Francisco Reyes 
Tip: 43      Comments: 0
You can use "whereis" to locate standard binary, manual page and source
directories for the specified programs. This can be particularly handy
when you are trying to find where in the ports tree an application is.

Try "whereis netscape" and "whereis whereis".
		-- Konstantinos Konstantinidis 
Tip: 44      Comments: 0
You can press Ctrl-D to quickly exit from a shell, or logout from a
login shell.
		-- Konstantinos Konstantinidis 
Tip: 45      Comments: 0
You can use "pkg_info" to see a list of packages you have installed.
		-- Konstantinos Konstantinidis 
Tip: 46      Comments: 0
You can change the video mode on all consoles by adding something like
the following to /etc/rc.conf:

	allscreens="80x30"

You can use "vidcontrol -i mode | grep T" for a list of supported text
modes.
		-- Konstantinos Konstantinidis 
Tip: 47      Comments: 0
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 
Tip: 48      Comments: 0
Over quota?  "du -s * | sort -n " will give you a sorted list of your
directory sizes.
		-- David Scheidt 
Tip: 49      Comments: 0
Handy bash(1) prompt:   PS1="\u@\h \w \!$ "
		-- David Scheidt 
Tip: 50      Comments: 0
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 
Tip: 51      Comments: 0
"man hier" will explain the way FreeBSD filesystems are normally laid out.
		-- David Scheidt 
Tip: 52      Comments: 1
"man tuning" gives some tips how to tune performance of your FreeBSD system.
		-- David Scheidt 
Tip: 53      Comments: 0
"man firewall" will give advice for building a FreeBSD firewall
		-- David Scheidt 
Tip: 54      Comments: 0
You can often get answers to your questions about FreeBSD by searching in the
FreeBSD mailing list archives at

	http://www.freebsd.org/search.html
Tip: 55      Comments: 2
You can adjust the volume of various parts of the sound system in your
computer by typing 'mixer  '.  To get a list of what you can
adjust, just type 'mixer'.
Tip: 56      Comments: 0
You can automatically download and install binary packages by doing

	pkg_add -r 

where you replace  with the URL to the package.  This will also
automatically install the packages the package you download is dependent on
(ie, the packages it needs in order to work.)
Tip: 57      Comments: 0
You can get a good standard workstation install by using the
instant-workstation port/package.  If you have ports installed, you can
install it by doing

	# cd /usr/ports/misc/instant-workstation
	# make install && make clean

as root.  This will install a collection of packages that is convenient to
have on a workstation.
Tip: 58      Comments: 0
You can get a good generic server install by using the
instant-server port/package.  If you have ports installed, you can
install it by doing

	# cd /usr/ports/misc/instant-server
	# make install && make clean

as root.  This will install a collection of packages that is appropriate for
running a "generic" server.
Tip: 59      Comments: 0
You can make a log of your terminal session with script(1).
Tip: 60      Comments: 0
"man ports" gives many useful hints about installing FreeBSD ports.
Tip: 61      Comments: 0
"man security" gives very good advice on how to tune the security of your
FreeBSD system.
Tip: 62      Comments: 0
Want to find a specific port, just type the following under /usr/ports,
or one its subdirectories:

	"make search port="
    or
	"make search key=""
Tip: 63      Comments: 0
Want to see how much virtual memory you're using? Just type "swapinfo" to
be shown information about the usage of your swap partitions.
Tip: 64      Comments: 0
ports/net/netcat port is useful not only for redirecting input/output
to TCP or UDP connections, but also for proxying them. See inetd(8) for
details.
Tip: 65      Comments: 0
If other operating systems have damaged your Master Boot Record, you can
reinstall it either with /stand/sysinstall or with boot0cfg(8). See
"man boot0cfg" for details.
Tip: 66      Comments: 0
Need to see the calendar for this month? Simply type "cal".  To see the
whole year, type "cal -y".
		-- Dru 
Tip: 67      Comments: 0
Need to quickly return to your home directory? Type "cd".
		-- Dru 
Tip: 68      Comments: 0
To see the last time that you logged in, use lastlogin(8).
		-- Dru 
Tip: 69      Comments: 0
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 
Tip: 70      Comments: 0
To save disk space in your home directory, compress files you rarely
use with "gzip  filename".
		-- Dru 
Tip: 71      Comments: 0
To read a compressed file without having to first uncompress it, use
"zcat" or "zmore" to view it.
		-- Dru 
Tip: 72      Comments: 0
To see how much disk space is left on your partitions, use

	df -h
		-- Dru 
Tip: 73      Comments: 0
To see the 10 largest files on a directory or partition, use

	du /partition_or_directory_name | sort -rn | head
		-- Dru 
Tip: 74      Comments: 0
To determine whether a file is a text file, executable, or some other type
of file, use

	file filename
		-- Dru 
Tip: 75      Comments: 0
Time to change your password? Type "passwd" and follow the prompts.
		-- Dru 
Tip: 76      Comments: 0
Want to know how many words, lines, or bytes are contained in a file? Type
"wc filename".
		-- Dru 
Tip: 77      Comments: 0
Need to print a manpage? Use

	man name_of_manpage | col -bx | lpr
		-- Dru 
Tip: 78      Comments: 0
Need to remove all those ^M characters from a DOS file? Try

	col -bx < dosfile > newfile
		-- Dru 
Tip: 79      Comments: 0
Forget what directory you are in? Type "pwd".
		-- Dru 
Tip: 80      Comments: 0
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 
Tip: 81      Comments: 0
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 
Tip: 82      Comments: 0
Need to find the location of a program? Use "locate program_name".
		-- Dru 
Tip: 83      Comments: 1
Forget how to spell a word or a variation of a word? Use

	"look portion_of_word_you_know
		-- Dru 
Tip: 84      Comments: 0
To see the last 10 lines of a long file, use "tail filename". To see the
first 10 lines, use "head filename".
		-- Dru 
Tip: 85      Comments: 0
To see how long it takes a command to run, type the word "time" before the
command name.
		-- Dru 
Tip: 86      Comments: 1
To quickly create an empty file, use "touch filename".
		-- Dru 
Tip: 87      Comments: 0
To find out the hostname associated with an IP address, use

	dig -x IP_address
		-- Dru 
Tip: 88      Comments: 0
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 
Tip: 89      Comments: 0
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 
Tip: 90      Comments: 0
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 
Tip: 91      Comments: 0
Forget when Easter is? Try "ncal -e". If you need the date for Orthodox
Easter, use "ncal -o" instead.
		-- Dru 
Tip: 92      Comments: 0
Need to see your routing table? Type "netstat -rn". The entry with the G
flag is your gateway.
		-- Dru 
Tip: 93      Comments: 0
Need to see which daemons are listening for connection requests? Use
"sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6.
		-- Dru 
Tip: 94      Comments: 0
Can't remember if you've installed a certain port or not? Try "pkg_info |
grep port_name".
		-- Dru 
Tip: 95      Comments: 0
To erase a line you've written at the command prompt, use "Ctrl-U".
		-- Dru 
Tip: 96      Comments: 0
To repeat the last command in the C shell, type "!!".
		-- Dru 
Tip: 97      Comments: 0
Need to quickly empty a file? Use ": > filename".
		-- Dru 
Tip: 98      Comments: 0
To see all of the directories on your FreeBSD system, type

	ls -R / | more
		-- Dru 
Tip: 99      Comments: 0
To see the IP addresses currently set on your active interfaces, type
"ifconfig -u".
		-- Dru 
Tip: 100      Comments: 0
To see the MAC addresses of the NICs on your system, type

	ifconfig -a
		-- Dru 
Tip: 101      Comments: 0
You can open up a new split-screen window in (n)vi with :N or :E and then
use ^w to switch between the two.
Tip: 102      Comments: 0
sh (the default bourne shell in FreeBSD) supports command-line editing.  Just
``set -o emacs'' or ``set -o vi'' to enable it.
Tip: 103      Comments: 0
When you've made modifications to a file in vi(1) and then find that
you can't write it, type ``!rm -f \%'' then ``:w!'' to force the
write

This won't work if you don't have write permissions to the directory
and probably won't be suitable if you're editing through a symbolic link.
Tip: 104      Comments: 0
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'
Page 0 of 0
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service