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