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