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