freebsd-tips revision 78266
178266SnikThis fortune brought to you by:
278266Snik$FreeBSD: head/games/fortune/datfiles/freebsd-tips 78266 2001-06-15 08:45:43Z nik $
378266Snik%
478266SnikHaving trouble using FTP through a firewall?  Try setting the environment
578266Snikvariable FTP_PASSIVE_MODE to yes, and see ftp(1) for more details.
678266Snik%
778266SnikBy pressing "Scroll Lock" you can use the arrow keys to scroll backward
878266Snikthrough the console output.  Press "Scroll Lock" again to turn it off.
978266Snik%
1078266SnikWant colour in your directory listings?  Use "ls -G".  "ls -F" is also useful,
1178266Snikand they can be combined as "ls -FG".
1278266Snik%
1378266SnikIf you need to ask a question on the FreeBSD-questions mailing list then
1478266Snik
1578266Snik	http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\
1678266Snik		freebsd-questions/index.html
1778266Snik
1878266Snikcontains lots of useful advice to help you get the best results.
1978266Snik%
2078266SnikIf you'd like to keep track of applications in the FreeBSD ports tree, take a
2178266Sniklook at FreshPorts;
2278266Snik
2378266Snik	http://www.freshports.org/
2478266Snik%
2578266SnikTo search for files that match a particular name, use find(1); for example
2678266Snik
2778266Snik	find / -name "*GENERIC*" -ls
2878266Snik
2978266Snikwill search '/', and all subdirectories, for files with 'GENERIC' in the name.
3078266Snik      	--  Stephen Hilton <nospam@hiltonbsd.com>
3178266Snik%
3278266SnikIn tcsh, you can `set autolist' to have the shell automatically show
3378266Snikall the possible matches when doing filename/directory expansion.
3478266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
3578266Snik%
3678266SnikYou can `set autologout = 30' to have tcsh log you off automatically
3778266Snikif you leave the shell idle for more than 30 seconds.
3878266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
3978266Snik%
4078266SnikIf you `set filec' (file completion) in tcsh and write a part of the
4178266Snikfilename, pressing TAB will show you the available choices when there
4278266Snikis more than one, or complete the filename if there's only one match.
4378266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
4478266Snik%
4578266SnikYou can press up-arrow or down-arrow to walk through a list of
4678266Snikprevious commands in tcsh.
4778266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
4878266Snik%
4978266SnikYou can disable tcsh's terminal beep if you `set nobeep'.
5078266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
5178266Snik%
5278266SnikIf you `set watch (0 any any)' in tcsh, you will be notified when
5378266Sniksomeone logs in or out of your system.
5478266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
5578266Snik%
5678266SnikNice tcsh prompt: set prompt = '%m %# '
5778266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
5878266Snik%
5978266SnikNice tcsh prompt: set prompt = '%n@%m%# '
6078266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
6178266Snik%
6278266SnikNice tcsh prompt: set prompt = '%n@%m:%~%# '
6378266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
6478266Snik%
6578266SnikNice tcsh prompt: set prompt = '%n@%m:%/%# '
6678266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
6778266Snik%
6878266SnikNice tcsh prompt: set prompt = '[%B%m%b] %B%~%b%# '
6978266Snik%
7078266SnikSimple tcsh prompt: set prompt = '%# '
7178266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
7278266Snik%
7378266SnikIf you want df(1) and other commands to display disk sizes in
7478266Snikkilobytes instead of 512-byte blocks, set BLOCKSIZE in your
7578266Snikenvironment to 'K'.
7678266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
7778266Snik%
7878266SnikTo change an environment variable in tcsh you use: setenv NAME "value"
7978266Snikwhere NAME is the name of the variable and "value" its new value.
8078266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
8178266Snik%
8278266SnikTo change an environment variable in /bin/sh use:
8378266Snik
8478266Snik	$ VARIABLE="value"
8578266Snik	$ export VARIABLE
8678266Snik		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
8778266Snik%
8878266Snik/etc/make.conf contains overrides to /etc/defaults/make.conf, which
8978266Snikcontrols the options used to compile software on this system.
9078266Snik%
9178266SnikTo do a fast search for a file, try
9278266Snik
9378266Snik	 locate filename
9478266Snik
9578266Sniklocate uses a database that is updated every saturday (assuming your computer
9678266Snikis running FreeBSD at the time) to quickly find files based on name only.
9778266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
9878266Snik%
9978266SnikIn order to search for a string in some files, use 'grep' like this:
10078266Snik
10178266Snik	 grep "string" filename1 [filename2 filename3 ...]
10278266Snik
10378266SnikThis will print out the lines in the files that contain the string.  grep can
10478266Snikalso do a lot more advanced searches - type 'man grep' for details.
10578266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
10678266Snik%
10778266SnikYou can use the 'fetch' command to retrieve files over ftp or http.
10878266Snik
10978266Snik	 fetch http://www.freebsd.org/index.html
11078266Snik
11178266Snikwill download the front page of the FreeBSD web site.
11278266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
11378266Snik%
11478266SnikIn order to make fetch (the FreeBSD downloading tool) ask for
11578266Snikusername/password when it encounter a password-protected web page, you can set
11678266Snikthe environment variable HTTP_AUTH to 'basic:*'.
11778266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
11878266Snik%
11978266SnikYou can permanently set environment variables for your shell by putting them
12078266Snikin a startup file for the shell.  The name of the startup file varies
12178266Snikdepending on the shell - csh and tcsh uses .cshrc, bash uses .bashrc, zsh uses
12278266Snik.zshrc, ksh uses .kshrc, and the Bourne shell (/bin/sh) uses .profile (and
12378266Snikthrough a little bit of trickery in .profile also .shrc)
12478266SnikOther shells will often also read .profile
12578266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
12678266Snik%
12778266SnikIf you are running xterm, the default TERM variable will be 'xterm'.  If you
12878266Snikset this environment variable to 'xterm-color' instead, a lot of programs will
12978266Snikuse colors.  You can do this by
13078266Snik
13178266Snik	TERM=xterm-color; export TERM
13278266Snik
13378266Snikin Bourne-derived shells, and
13478266Snik
13578266Snik	setenv TERM xterm-color
13678266Snik
13778266Snikin csh-derived shells.
13878266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
13978266Snik%
14078266SnikIf you accidently drop into /bin/sh (e.g, due to a computer failure where you
14178266Snikend up in single user mode), you can make the cursor keys work by typing
14278266Snik
14378266Snik	set -E
14478266Snik
14578266SnikThe E represents the initial E in Emacs (for emacs keys).
14678266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
14778266Snik%
14878266SnikIf you do not want to get beeps in X11 (X Windows), you can turn them off with
14978266Snik
15078266Snik	xset b off
15178266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
15278266Snik%
15378266SnikYou can look through a file in a nice text-based interface by typing
15478266Snik
15578266Snik	less filename
15678266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
15778266Snik%
15878266SnikThe default editor in FreeBSD is vi, which is efficient to use when you have
15978266Sniklearned it, but somewhat user-unfriendly.  To use ee (an easier but less
16078266Snikpowerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
16178266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
16278266Snik%
16378266SnikIf you accidently end up inside vi, you can quit it by pressing Escape, colon
16478266Snik(:), q (q), bang (!) and pressing return.
16578266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
16678266Snik%
16778266SnikYou can use aliases to decrease the amount of typing you need to do to get
16878266Snikcommands you commonly use.  Examples of fairly popular aliases include (in
16978266Snikbourne shell style, as in /bin/sh, bash, ksh, and zsh):
17078266Snik
17178266Snik	alias lf="ls -FA"
17278266Snik	alias ll="ls -lA"
17378266Snik	alias su="su -m"
17478266Snik
17578266SnikIn csh or tcsh, these would be
17678266Snik
17778266Snik	alias lf ls -FA
17878266Snik	alias ll ls -lA
17978266Snik	alias su su -m
18078266Snik
18178266SnikTo remove an alias, you can usually use 'unalias aliasname'.  To list all
18278266Snikaliases, you can usually type just 'alias'.
18378266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
18478266Snik%
18578266SnikIn order to support national characters for european languages in tools like
18678266Snikless without creating other nationalisation aspects, set the environment
18778266Snikvariable LC_ALL to 'en_US.ISO8859-1'.
18878266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
18978266Snik%
19078266SnikYou can search for documentation on a keyword by typing
19178266Snik
19278266Snik	apropos keyword
19378266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
19478266Snik%
19578266SnikMan pages are divided into section depending on topic.  There are 9 different
19678266Sniksections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual).
19778266SnikYou can get an introduction to each topic by typing
19878266Snik
19978266Snik	man <number> intro
20078266Snik
20178266SnikIn other words, to get the intro to general commands, type
20278266Snik
20378266Snik	man 1 intro
20478266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
20578266Snik%
20678266SnikFreeBSD is started up by the program 'init'.  The first thing init does when
20778266Snikstarting multiuser mode (ie, starting the computer up for normal use) is to
20878266Snikrun the shell script /etc/rc.  By reading /etc/rc, you can learn a lot about
20978266Snikhow the system is put together, which again will make you more confident about
21078266Snikwhat happens when you do something with it.
21178266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
21278266Snik%
21378266SnikIf you want to play CDs with FreeBSD, a utility for this is already included.
21478266SnikType 'cdcontrol' then 'help' to learn more.  (You may need to set the CDROM
21578266Snikenvironment variable in order to make cdcontrol want to start.)
21678266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
21778266Snik%
21878266SnikIf you have a CD-ROM drive in your machine, you can make the CD-ROM that is
21978266Snikpresently inserted available by typing 'mount /cdrom' as root.   The CD-ROM
22078266Snikwill be available under /cdrom/.  Remember to do 'unmount /cdrom' before
22178266Snikremoving the CD-ROM (it will usually not be possible to remove the CD-ROM
22278266Snikwithout doing this.)
22378266Snik
22478266SnikNote: This tip may not work in all configurations.
22578266Snik		--  Eivind Eklund <eivind@FreeBSD.org>
22678266Snik%
22778266SnikYou can install extra packages for FreeBSD by using the ports system.
22878266SnikIf you have installed it, you can download, compile, and install software by
22978266Snikjust typing
23078266Snik
23178266Snik	# cd /usr/ports/<category>/<portname>
23278266Snik	# make install && make clean
23378266Snik
23478266Snikas root.   The ports infrastructure will download the software, change it so
23578266Snikit works on FreeBSD, compile it, install it, register the installation so it
23678266Snikwill be possible to automatically uninstall it, and clean out the temporary
23778266Snikworking space it used.  You can remove an installed port you decide you do not
23878266Snikwant after all by typing
23978266Snik
24078266Snik	# cd /usr/ports/<category>/<portname>
24178266Snik	# make deinstall
24278266Snik
24378266Snikas root.
24478266Snik		-- Eivind Eklund <eivind@FreeBSD.org>
24578266Snik%
24678266SnikNice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
24778266Snik		-- Mathieu <mathieu@hal.interactionvirtuelle.com>
24878266Snik%
24978266SnikTo see the output from when your computer started, run dmesg(8).  If it has
25078266Snikbeen replaced with other messages, look at /var/run/dmesg.boot.
25178266Snik		-- Francisco Reyes <lists@natserv.com>
25278266Snik%
25378266SnikYou can use "whereis" to locate standard binary, manual page and source
25478266Snikdirectories for the specified programs. This can be particularly handy
25578266Snikwhen you are trying to find where in the ports tree an application is.
25678266Snik
25778266SnikTry "whereis netscape" and "whereis whereis".
25878266Snik		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
25978266Snik%
26078266SnikYou can press Ctrl-D to quickly exit from a shell, or logout from a
26178266Sniklogin shell.
26278266Snik		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
26378266Snik%
26478266SnikYou can use "pkg_info" to see a list of packages you have installed.
26578266Snik		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
26678266Snik%
26778266SnikYou can change the video mode on all consoles by adding something like
26878266Snikthe following to /etc/rc.conf:
26978266Snik
27078266Snik	allscreens="80x30"
27178266Snik
27278266SnikYou can use "vidcontrol -i mode | grep T" for a list of supported text
27378266Snikmodes.
27478266Snik		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
27578266Snik%
27678266SnikAny user that is a member of the wheel group can use "su -" to simulate
27778266Snika root login. You can add a user to the wheel group by editing /etc/group.
27878266Snik		-- 	-- Konstantinos Konstantinidis <kkonstan@duth.gr>
279