Merge from vendor branch NCURSES:
[dragonfly.git] / games / fortune / datfiles / freebsd-tips
1 This fortune brought to you by:
2 $FreeBSD: src/games/fortune/datfiles/freebsd-tips,v 1.14.2.11 2003/03/15 08:48:29 dougb Exp $
3 $DragonFly: src/games/fortune/datfiles/Attic/freebsd-tips,v 1.2 2003/06/17 04:25:24 dillon Exp $
4 %
5 Having trouble using fetch through a firewall? Try setting the environment
6 variable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
7 %
8 By pressing "Scroll Lock" you can use the arrow keys to scroll backward
9 through the console output.  Press "Scroll Lock" again to turn it off.
10 %
11 Want colour in your directory listings?  Use "ls -G".  "ls -F" is also useful,
12 and they can be combined as "ls -FG".
13 %
14 If you need to ask a question on the FreeBSD-questions mailing list then
15
16         http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\
17                 freebsd-questions/index.html
18
19 contains lots of useful advice to help you get the best results.
20 %
21 If you'd like to keep track of applications in the FreeBSD ports tree, take a
22 look at FreshPorts;
23
24         http://www.freshports.org/
25 %
26 To search for files that match a particular name, use find(1); for example
27
28         find / -name "*GENERIC*" -ls
29
30 will search '/', and all subdirectories, for files with 'GENERIC' in the name.
31         --  Stephen Hilton <nospam@hiltonbsd.com>
32 %
33 In tcsh, you can `set autolist' to have the shell automatically show
34 all the possible matches when doing filename/directory expansion.
35 %
36 You can `set autologout = 30' to have tcsh log you off automatically
37 if you leave the shell idle for more than 30 minutes.
38 %
39 If you `set filec' (file completion) in tcsh and write a part of the
40 filename, pressing TAB will show you the available choices when there
41 is more than one, or complete the filename if there's only one match.
42 %
43 You can press up-arrow or down-arrow to walk through a list of
44 previous commands in tcsh.
45 %
46 You can disable tcsh's terminal beep if you `set nobeep'.
47 %
48 If you `set watch = (0 any any)' in tcsh, you will be notified when
49 someone logs in or out of your system.
50 %
51 Nice tcsh prompt: set prompt = '%m %# '
52 %
53 Nice tcsh prompt: set prompt = '%n@%m%# '
54 %
55 Nice tcsh prompt: set prompt = '%n@%m:%~%# '
56 %
57 Nice tcsh prompt: set prompt = '%n@%m:%/%# '
58 %
59 Nice tcsh prompt: set prompt = '[%B%m%b] %B%~%b%# '
60 %
61 Simple tcsh prompt: set prompt = '%# '
62 %
63 If you want df(1) and other commands to display disk sizes in
64 kilobytes instead of 512-byte blocks, set BLOCKSIZE in your
65 environment to 'K'.  You can also use 'M' for Megabytes or 'G' for
66 Gigabytes.  If you want df(1) to automatically select the best size
67 then use 'df -h'.
68 %
69 To change an environment variable in tcsh you use: setenv NAME "value"
70 where NAME is the name of the variable and "value" its new value.
71 %
72 To change an environment variable in /bin/sh use:
73
74         $ VARIABLE="value"
75         $ export VARIABLE
76 %
77 You can use /etc/make.conf to control the options used to compile software
78 on this system.  Example entries are in
79 /etc/defaults/make.conf.
80 %
81 To do a fast search for a file, try
82
83          locate filename
84
85 locate uses a database that is updated every Saturday (assuming your computer
86 is running FreeBSD at the time) to quickly find files based on name only.
87 %
88 In order to search for a string in some files, use 'grep' like this:
89
90          grep "string" filename1 [filename2 filename3 ...]
91
92 This will print out the lines in the files that contain the string.  grep can
93 also do a lot more advanced searches - type 'man grep' for details.
94 %
95 You can use the 'fetch' command to retrieve files over ftp or http.
96
97          fetch http://www.freebsd.org/index.html
98
99 will download the front page of the FreeBSD web site.
100 %
101 In order to make fetch (the FreeBSD downloading tool) ask for
102 username/password when it encounter a password-protected web page, you can set
103 the environment variable HTTP_AUTH to 'basic:*'.
104 %
105 You can permanently set environment variables for your shell by putting them
106 in a startup file for the shell.  The name of the startup file varies
107 depending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use
108 .profile.  When using bash, sh, ksh or zsh, don't forget to export the
109 variable.
110 %
111 If you are running xterm, the default TERM variable will be 'xterm'.  If you
112 set this environment variable to 'xterm-color' instead, a lot of programs will
113 use colors.  You can do this by
114
115         TERM=xterm-color; export TERM
116
117 in Bourne-derived shells, and
118
119         setenv TERM xterm-color
120
121 in csh-derived shells.
122 %
123 If you do not want to get beeps in X11 (X Windows), you can turn them off with
124
125         xset b off
126 %
127 You can look through a file in a nice text-based interface by typing
128
129         less filename
130 %
131 The default editor in FreeBSD is vi, which is efficient to use when you have
132 learned it, but somewhat user-unfriendly.  To use ee (an easier but less
133 powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
134 %
135 If you accidently end up inside vi, you can quit it by pressing Escape, colon
136 (:), q (q), bang (!) and pressing return.
137 %
138 You can use aliases to decrease the amount of typing you need to do to get
139 commands you commonly use.  Examples of fairly popular aliases include (in
140 bourne shell style, as in /bin/sh, bash, ksh, and zsh):
141
142         alias lf="ls -FA"
143         alias ll="ls -lA"
144         alias su="su -m"
145
146 In csh or tcsh, these would be
147
148         alias lf ls -FA
149         alias ll ls -lA
150         alias su su -m
151
152 To remove an alias, you can usually use 'unalias aliasname'.  To list all
153 aliases, you can usually type just 'alias'.
154 %
155 In order to support national characters for european languages in tools like
156 less without creating other nationalisation aspects, set the environment
157 variable LC_ALL to 'en_US.ISO8859-1'.
158 %
159 You can search for documentation on a keyword by typing
160
161         apropos keyword
162 %
163 Man pages are divided into section depending on topic.  There are 9 different
164 sections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual).
165 You can get an introduction to each topic by typing
166
167         man <number> intro
168
169 In other words, to get the intro to general commands, type
170
171         man 1 intro
172 %
173 FreeBSD is started up by the program 'init'.  The first thing init does when
174 starting multiuser mode (ie, starting the computer up for normal use) is to
175 run the shell script /etc/rc.  By reading /etc/rc, you can learn a lot about
176 how the system is put together, which again will make you more confident about
177 what happens when you do something with it.
178 %
179 If you want to play CDs with FreeBSD, a utility for this is already included.
180 Type 'cdcontrol' then 'help' to learn more.  (You may need to set the CDROM
181 environment variable in order to make cdcontrol want to start.)
182 %
183 If you have a CD-ROM drive in your machine, you can make the CD-ROM that is
184 presently inserted available by typing 'mount /cdrom' as root.   The CD-ROM
185 will be available under /cdrom/.  Remember to do 'umount /cdrom' before
186 removing the CD-ROM (it will usually not be possible to remove the CD-ROM
187 without doing this.)
188
189 Note: This tip may not work in all configurations.
190 %
191 You can install extra packages for FreeBSD by using the ports system.
192 If you have installed it, you can download, compile, and install software by
193 just typing
194
195         # cd /usr/ports/<category>/<portname>
196         # make install && make clean
197
198 as root.   The ports infrastructure will download the software, change it so
199 it works on FreeBSD, compile it, install it, register the installation so it
200 will be possible to automatically uninstall it, and clean out the temporary
201 working space it used.  You can remove an installed port you decide you do not
202 want after all by typing
203
204         # cd /usr/ports/<category>/<portname>
205         # make deinstall
206
207 as root.
208 %
209 Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
210                 -- Mathieu <mathieu@hal.interactionvirtuelle.com>
211 %
212 To see the output from when your computer started, run dmesg(8).  If it has
213 been replaced with other messages, look at /var/run/dmesg.boot.
214                 -- Francisco Reyes <lists@natserv.com>
215 %
216 You can use "whereis" to locate standard binary, manual page and source
217 directories for the specified programs. This can be particularly handy
218 when you are trying to find where in the ports tree an application is.
219
220 Try "whereis netscape" and "whereis whereis".
221                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
222 %
223 You can press Ctrl-D to quickly exit from a shell, or logout from a
224 login shell.
225                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
226 %
227 You can use "pkg_info" to see a list of packages you have installed.
228                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
229 %
230 You can change the video mode on all consoles by adding something like
231 the following to /etc/rc.conf:
232
233         allscreens="80x30"
234
235 You can use "vidcontrol -i mode | grep T" for a list of supported text
236 modes.
237                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
238 %
239 Any user that is a member of the wheel group can use "su -" to simulate
240 a root login. You can add a user to the wheel group by editing /etc/group.
241                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
242 %
243 Over quota?  "du -s * | sort -n " will give you a sorted list of your
244 directory sizes.
245                 -- David Scheidt <dscheidt@tumbolia.com>
246 %
247 Handy bash(1) prompt:   PS1="\u@\h \w \!$ "
248                 -- David Scheidt <dscheidt@tumbolia.com>
249 %
250 Ever wonder what those numbers after command names were, as in cat(1)?  It's
251 the section of the manual the man page is in.  "man man" will tell you more.
252                 -- David Scheidt <dscheidt@tumbolia.com>
253 %
254 "man hier" will explain the way FreeBSD filesystems are normally laid out.
255                 -- David Scheidt <dscheidt@tumbolia.com>
256 %
257 "man tuning" gives some tips how to tune performance of your FreeBSD system.
258                 -- David Scheidt <dscheidt@tumbolia.com>
259 %
260 "man firewall" will give advice for building a FreeBSD firewall
261                 -- David Scheidt <dscheidt@tumbolia.com>
262 %
263 You can often get answers to your questions about FreeBSD by searching in the
264 FreeBSD mailing list archives at
265
266         http://www.freebsd.org/search.html
267 %
268 You can adjust the volume of various parts of the sound system in your
269 computer by typing 'mixer <type> <volume>'.  To get a list of what you can
270 adjust, just type 'mixer'.
271 %
272 You can automatically download and install binary packages by doing
273
274         pkg_add -r <URL>
275
276 where you replace <URL> with the URL to the package.  This will also
277 automatically install the packages the package you download is dependent on
278 (ie, the packages it needs in order to work.)
279 %
280 You can get a good standard workstation install by using the
281 instant-workstation port/package.  If you have ports installed, you can
282 install it by doing
283
284         # cd /usr/ports/misc/instant-workstation
285         # make install && make clean
286
287 as root.  This will install a collection of packages that is convenient to
288 have on a workstation.
289 %
290 You can get a good generic server install by using the
291 instant-server port/package.  If you have ports installed, you can
292 install it by doing
293
294         # cd /usr/ports/misc/instant-server
295         # make install && make clean
296
297 as root.  This will install a collection of packages that is appropriate for
298 running a "generic" server.
299 %
300 You can make a log of your terminal session with script(1).
301 %
302 "man ports" gives many useful hints about installing FreeBSD ports.
303 %
304 "man security" gives very good advice on how to tune the security of your
305 FreeBSD system.
306 %
307 Want to find a specific port, just type the following under /usr/ports,
308 or one its subdirectories:
309
310         "make search port=<port-name>"
311     or
312         "make search key="<keyword>"
313 %
314 Want to see how much virtual memory you're using? Just type "swapinfo" to
315 be shown information about the usage of your swap partitions.
316 %
317 ports/net/netcat port is useful not only for redirecting input/output
318 to TCP or UDP connections, but also for proxying them. See inetd(8) for
319 details.
320 %
321 If other operating systems have damaged your Master Boot Record, you can
322 reinstall it either with /stand/sysinstall or with boot0cfg(8). See
323 "man boot0cfg" for details.
324 %
325 Need to see the calendar for this month? Simply type "cal".  To see the
326 whole year, type "cal -y".
327                 -- Dru <genesis@istar.ca>
328 %
329 Need to quickly return to your home directory? Type "cd".
330                 -- Dru <genesis@istar.ca>
331 %
332 To see the last time that you logged in, use lastlogin(8).
333                 -- Dru <genesis@istar.ca>
334 %
335 To clear the screen, use "clear". To re-display your screen buffer, press
336 the scroll lock key and use your page up button. When you're finished,
337 press the scroll lock key again to get your prompt back.
338                 -- Dru <genesis@istar.ca>
339 %
340 To save disk space in your home directory, compress files you rarely
341 use with "gzip filename".
342                 -- Dru <genesis@istar.ca>
343 %
344 To read a compressed file without having to first uncompress it, use
345 "zcat" or "zmore" to view it.
346                 -- Dru <genesis@istar.ca>
347 %
348 To see how much disk space is left on your partitions, use
349
350         df -h
351                 -- Dru <genesis@istar.ca>
352 %
353 To see the 10 largest files on a directory or partition, use
354
355         du /partition_or_directory_name | sort -rn | head
356                 -- Dru <genesis@istar.ca>
357 %
358 To determine whether a file is a text file, executable, or some other type
359 of file, use
360
361         file filename
362                 -- Dru <genesis@istar.ca>
363 %
364 Time to change your password? Type "passwd" and follow the prompts.
365                 -- Dru <genesis@istar.ca>
366 %
367 Want to know how many words, lines, or bytes are contained in a file? Type
368 "wc filename".
369                 -- Dru <genesis@istar.ca>
370 %
371 Need to print a manpage? Use
372
373         man name_of_manpage | col -bx | lpr
374                 -- Dru <genesis@istar.ca>
375 %
376 Need to remove all those ^M characters from a DOS file? Try
377
378         col -bx < dosfile > newfile
379                 -- Dru <genesis@istar.ca>
380 %
381 Forget what directory you are in? Type "pwd".
382                 -- Dru <genesis@istar.ca>
383 %
384 If you are in the C shell and have just installed a new program, you won't
385 be able to run it unless you first type "rehash".
386                 -- Dru <genesis@istar.ca>
387 %
388 Need to leave your terminal for a few minutes and don't want to logout?
389 Use "lock -p". When you return, use your password as the key to unlock the
390 terminal.
391                 -- Dru <genesis@istar.ca>
392 %
393 Need to find the location of a program? Use "locate program_name".
394                 -- Dru <genesis@istar.ca>
395 %
396 Forget how to spell a word or a variation of a word? Use
397
398         look portion_of_word_you_know
399                 -- Dru <genesis@istar.ca>
400 %
401 To see the last 10 lines of a long file, use "tail filename". To see the
402 first 10 lines, use "head filename".
403                 -- Dru <genesis@istar.ca>
404 %
405 To see how long it takes a command to run, type the word "time" before the
406 command name.
407                 -- Dru <genesis@istar.ca>
408 %
409 To quickly create an empty file, use "touch filename".
410                 -- Dru <genesis@istar.ca>
411 %
412 To find out the hostname associated with an IP address, use
413
414         dig -x IP_address
415                 -- Dru <genesis@istar.ca>
416 %
417 If you use the C shell, add the following line to the .cshrc file in your
418 home directory to prevent core files from being written to disk:
419
420         limit coredumpsize 0
421                 -- Dru <genesis@istar.ca>
422 %
423 If you need a reminder to leave your terminal, type "leave +hhmm" where
424 "hhmm" represents in how many hours and minutes you need to leave.
425                 -- Dru <genesis@istar.ca>
426 %
427 Need to do a search in a manpage or in a file you've sent to a pager? Use
428 "/search_word". To repeat the same search, type "n" for next.
429                 -- Dru <genesis@istar.ca>
430 %
431 Forget when Easter is? Try "ncal -e". If you need the date for Orthodox
432 Easter, use "ncal -o" instead.
433                 -- Dru <genesis@istar.ca>
434 %
435 Need to see your routing table? Type "netstat -rn". The entry with the G
436 flag is your gateway.
437                 -- Dru <genesis@istar.ca>
438 %
439 Need to see which daemons are listening for connection requests? Use
440 "sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6.
441                 -- Dru <genesis@istar.ca>
442 %
443 Can't remember is you've installed a certain port or not? Try "pkg_info |
444 grep port_name".
445                 -- Dru <genesis@istar.ca>
446 %
447 Got some time to kill? Try typing "hangman".
448                 -- Dru <genesis@istar.ca>
449 %
450 To erase a line you've written at the command prompt, use "Ctrl-U".
451                 -- Dru <genesis@istar.ca>
452 %
453 To repeat the last command in the C shell, type "!!".
454                 -- Dru <genesis@istar.ca>
455 %
456 Need to quickly empty a file? Use "echo > filename".
457                 -- Dru <genesis@istar.ca>
458 %
459 To see all of the directories on your FreeBSD system, type
460
461         ls -R / | more
462                 -- Dru <genesis@istar.ca>
463 %
464 To see the IP addresses currently set on your active interfaces, type
465 "ifconfig -u".
466                 -- Dru <genesis@istar.ca>
467 %
468 To see the MAC addresses of the NICs on your system, type
469
470         ifconfig -a
471                 -- Dru <genesis@istar.ca>
472 %
473 You can save your kernel startup configuration with kget(8).  The
474 Configuration can be edited at boot time with 'boot -c' command in loader.
475 See boot(8), loader(8) for details.
476 %
477 You can open up a new split-screen window in (n)vi with :N or :E and then
478 use ^w to switch between the two.
479 %
480 sh (the default bourne shell in FreeBSD) supports command-line editing.  Just
481 ``set -o emacs'' or ``set -o vi'' to enable it.
482 %
483 When you've made modifications to a file in vi(1) and then find that
484 you can't write it, type ``<ESC>!rm -f %'' then ``:w!'' to force the
485 write
486
487 This won't work if you don't have write permissions to the directory
488 and probably won't be suitable if you're editing through a symbolic link.
489 %
490 If you want to quickly check for duplicate package/port installations,
491 try the following pkg_info command.
492
493         pkg_info | sort | sed -e 's/-[0-9].*$//' | \
494         uniq -c | grep -v '^[[:space:]]*1'
495 %
496 Want to use sed(1) to edit a file in place?  Well, to replace every 'e' with
497 an 'o', in a file named 'foo', you can do:
498
499         sed -i.bak s/e/o/g foo
500
501 And you'll get a backup of the original in a file named 'foo.bak', but if you
502 want no backup:
503
504         sed -i '' s/e/o/g foo