freebsd-tips revision 78352
1This fortune brought to you by:
2$FreeBSD: head/games/fortune/datfiles/freebsd-tips 78352 2001-06-16 11:42:28Z nik $
3%
4Having trouble using FTP through a firewall?  Try setting the environment
5variable FTP_PASSIVE_MODE to yes, and see ftp(1) for more details.
6%
7By pressing "Scroll Lock" you can use the arrow keys to scroll backward
8through the console output.  Press "Scroll Lock" again to turn it off.
9%
10Want colour in your directory listings?  Use "ls -G".  "ls -F" is also useful,
11and they can be combined as "ls -FG".
12%
13If you need to ask a question on the FreeBSD-questions mailing list then
14
15	http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\
16		freebsd-questions/index.html
17
18contains lots of useful advice to help you get the best results.
19%
20If you'd like to keep track of applications in the FreeBSD ports tree, take a
21look at FreshPorts;
22
23	http://www.freshports.org/
24%
25To search for files that match a particular name, use find(1); for example
26
27	find / -name "*GENERIC*" -ls
28
29will search '/', and all subdirectories, for files with 'GENERIC' in the name.
30      	--  Stephen Hilton <nospam@hiltonbsd.com>
31%
32In tcsh, you can `set autolist' to have the shell automatically show
33all the possible matches when doing filename/directory expansion.
34		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
35%
36You can `set autologout = 30' to have tcsh log you off automatically
37if you leave the shell idle for more than 30 seconds.
38		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
39%
40If you `set filec' (file completion) in tcsh and write a part of the
41filename, pressing TAB will show you the available choices when there
42is more than one, or complete the filename if there's only one match.
43		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
44%
45You can press up-arrow or down-arrow to walk through a list of
46previous commands in tcsh.
47		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
48%
49You can disable tcsh's terminal beep if you `set nobeep'.
50		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
51%
52If you `set watch (0 any any)' in tcsh, you will be notified when
53someone logs in or out of your system.
54		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
55%
56Nice tcsh prompt: set prompt = '%m %# '
57		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
58%
59Nice tcsh prompt: set prompt = '%n@%m%# '
60		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
61%
62Nice tcsh prompt: set prompt = '%n@%m:%~%# '
63		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
64%
65Nice tcsh prompt: set prompt = '%n@%m:%/%# '
66		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
67%
68Nice tcsh prompt: set prompt = '[%B%m%b] %B%~%b%# '
69%
70Simple tcsh prompt: set prompt = '%# '
71		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
72%
73If you want df(1) and other commands to display disk sizes in
74kilobytes instead of 512-byte blocks, set BLOCKSIZE in your
75environment to 'K'.
76		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
77%
78To change an environment variable in tcsh you use: setenv NAME "value"
79where NAME is the name of the variable and "value" its new value.
80		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
81%
82To change an environment variable in /bin/sh use:
83
84	$ VARIABLE="value"
85	$ export VARIABLE
86		--  Giorgos Keramidas <keramida@ceid.upatras.gr>
87%
88/etc/make.conf contains overrides to /etc/defaults/make.conf, which
89controls the options used to compile software on this system.
90%
91To do a fast search for a file, try
92
93	 locate filename
94
95locate uses a database that is updated every saturday (assuming your computer
96is running FreeBSD at the time) to quickly find files based on name only.
97%
98In order to search for a string in some files, use 'grep' like this:
99
100	 grep "string" filename1 [filename2 filename3 ...]
101
102This will print out the lines in the files that contain the string.  grep can
103also do a lot more advanced searches - type 'man grep' for details.
104%
105You can use the 'fetch' command to retrieve files over ftp or http.
106
107	 fetch http://www.freebsd.org/index.html
108
109will download the front page of the FreeBSD web site.
110%
111In order to make fetch (the FreeBSD downloading tool) ask for
112username/password when it encounter a password-protected web page, you can set
113the environment variable HTTP_AUTH to 'basic:*'.
114%
115You can permanently set environment variables for your shell by putting them
116in a startup file for the shell.  The name of the startup file varies
117depending on the shell - csh and tcsh uses .cshrc, bash uses .bashrc, zsh uses
118.zshrc, ksh uses .kshrc, and the Bourne shell (/bin/sh) uses .profile (and
119through a little bit of trickery in .profile also .shrc)
120Other shells will often also read .profile
121%
122If you are running xterm, the default TERM variable will be 'xterm'.  If you
123set this environment variable to 'xterm-color' instead, a lot of programs will
124use colors.  You can do this by
125
126	TERM=xterm-color; export TERM
127
128in Bourne-derived shells, and
129
130	setenv TERM xterm-color
131
132in csh-derived shells.
133%
134If you accidently drop into /bin/sh (e.g, due to a computer failure where you
135end up in single user mode), you can make the cursor keys work by typing
136
137	set -E
138
139The E represents the initial E in Emacs (for emacs keys).
140%
141If you do not want to get beeps in X11 (X Windows), you can turn them off with
142
143	xset b off
144%
145You can look through a file in a nice text-based interface by typing
146
147	less filename
148%
149The default editor in FreeBSD is vi, which is efficient to use when you have
150learned it, but somewhat user-unfriendly.  To use ee (an easier but less
151powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
152%
153If you accidently end up inside vi, you can quit it by pressing Escape, colon
154(:), q (q), bang (!) and pressing return.
155%
156You can use aliases to decrease the amount of typing you need to do to get
157commands you commonly use.  Examples of fairly popular aliases include (in
158bourne shell style, as in /bin/sh, bash, ksh, and zsh):
159
160	alias lf="ls -FA"
161	alias ll="ls -lA"
162	alias su="su -m"
163
164In csh or tcsh, these would be
165
166	alias lf ls -FA
167	alias ll ls -lA
168	alias su su -m
169
170To remove an alias, you can usually use 'unalias aliasname'.  To list all
171aliases, you can usually type just 'alias'.
172%
173In order to support national characters for european languages in tools like
174less without creating other nationalisation aspects, set the environment
175variable LC_ALL to 'en_US.ISO8859-1'.
176%
177You can search for documentation on a keyword by typing
178
179	apropos keyword
180%
181Man pages are divided into section depending on topic.  There are 9 different
182sections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual).
183You can get an introduction to each topic by typing
184
185	man <number> intro
186
187In other words, to get the intro to general commands, type
188
189	man 1 intro
190%
191FreeBSD is started up by the program 'init'.  The first thing init does when
192starting multiuser mode (ie, starting the computer up for normal use) is to
193run the shell script /etc/rc.  By reading /etc/rc, you can learn a lot about
194how the system is put together, which again will make you more confident about
195what happens when you do something with it.
196%
197If you want to play CDs with FreeBSD, a utility for this is already included.
198Type 'cdcontrol' then 'help' to learn more.  (You may need to set the CDROM
199environment variable in order to make cdcontrol want to start.)
200%
201If you have a CD-ROM drive in your machine, you can make the CD-ROM that is
202presently inserted available by typing 'mount /cdrom' as root.   The CD-ROM
203will be available under /cdrom/.  Remember to do 'unmount /cdrom' before
204removing the CD-ROM (it will usually not be possible to remove the CD-ROM
205without doing this.)
206
207Note: This tip may not work in all configurations.
208%
209You can install extra packages for FreeBSD by using the ports system.
210If you have installed it, you can download, compile, and install software by
211just typing
212
213	# cd /usr/ports/<category>/<portname>
214	# make install && make clean
215
216as root.   The ports infrastructure will download the software, change it so
217it works on FreeBSD, compile it, install it, register the installation so it
218will be possible to automatically uninstall it, and clean out the temporary
219working space it used.  You can remove an installed port you decide you do not
220want after all by typing
221
222	# cd /usr/ports/<category>/<portname>
223	# make deinstall
224
225as root.
226%
227Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
228		-- Mathieu <mathieu@hal.interactionvirtuelle.com>
229%
230To see the output from when your computer started, run dmesg(8).  If it has
231been replaced with other messages, look at /var/run/dmesg.boot.
232		-- Francisco Reyes <lists@natserv.com>
233%
234You can use "whereis" to locate standard binary, manual page and source
235directories for the specified programs. This can be particularly handy
236when you are trying to find where in the ports tree an application is.
237
238Try "whereis netscape" and "whereis whereis".
239		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
240%
241You can press Ctrl-D to quickly exit from a shell, or logout from a
242login shell.
243		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
244%
245You can use "pkg_info" to see a list of packages you have installed.
246		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
247%
248You can change the video mode on all consoles by adding something like
249the following to /etc/rc.conf:
250
251	allscreens="80x30"
252
253You can use "vidcontrol -i mode | grep T" for a list of supported text
254modes.
255		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
256%
257Any user that is a member of the wheel group can use "su -" to simulate
258a root login. You can add a user to the wheel group by editing /etc/group.
259		-- 	-- Konstantinos Konstantinidis <kkonstan@duth.gr>
260%
261Over quota?  "du -s * | sort -n " will give you a sorted list of your
262directory sizes.
263		-- David Scheidt <dscheidt@tumbolia.com>
264%
265Handy bash(1) prompt:   PS1="\u@\h \w \!$ "
266		-- David Scheidt <dscheidt@tumbolia.com>
267%
268man -k "something" will give you a list of manpages that have "something"
269in their description.
270		-- David Scheidt <dscheidt@tumbolia.com>
271%
272Ever wonder what those numbers after command names were, as in cat(1)?  It's
273the section of the manual the man page is in.  "man man" will tell you more.
274		-- David Scheidt <dscheidt@tumbolia.com>
275%
276"man hier" will explain the way FreeBSD filesystems are normally laid out.
277		-- David Scheidt <dscheidt@tumbolia.com>
278%
279"man tuning" gives some tips how to tune performance of your FreeBSD system.
280		-- David Scheidt <dscheidt@tumbolia.com>
281%
282"man firewall" will give advice for building a FreeBSD firewall
283		-- David Scheidt <dscheidt@tumbolia.com>
284%
285You can often get answers to your questions about FreeBSD by searching in the
286FreeBSD mailing list archives at
287
288	http://www.freebsd.org/search.html
289%
290You can adjust the volume of various parts of the sound system in your
291computer by typing 'mixer <type> <volume>'.  To get a list of what you can
292adjust, just type 'mixer'.
293%
294You can automatically download and install binary packages by doing
295
296	pkg_add -r <URL>
297
298where you replace <URL> with the URL to the package.  This will also
299automatically install the packages the package you download is dependent on
300(ie, the packages it needs in order to work.)
301%
302You can get a good standard workstation install by using the
303instant-workstation port/package.  If you have ports installed, you can
304install it by doing
305
306	# cd /usr/ports/misc/instant-workstation
307	# make install && make clean
308
309as root.  This will install a collection of packages that is convenient to
310have on a workstation.
311%
312You can get a good generic server install by using the
313instant-server port/package.  If you have ports installed, you can
314install it by doing
315
316	# cd /usr/ports/misc/instant-server
317	# make install && make clean
318
319as root.  This will install a collection of packages that is appropriate for
320running a "generic" server.
321% 
322You can make a log of you terminal session with script(1). 
323% 
324"man ports" gives many useful hints about installing FreeBSD ports. 
325% 
326ports/net/netcat port is useful not only for redirecting input/output 
327to TCP or UDP connections, but also for proxying them. See inetd(8) for 
328details. 
329% 
330If other operating systems have damaged your Master Boot Record, you can 
331reinstall it either with /stand/sysinstall or with boot0cfg(8). See 
332"man boot0cfg" for details.
333