]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/fortune/datfiles/freebsd-tips
Add ZFS usage tips to freebsd-tips.
[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 do not want to get beeps in X11 (X Windows), you can turn them off with
51
52         xset b off
53 %
54 If you have a CD-ROM drive in your machine, you can make the CD-ROM that is
55 presently inserted available by typing 'mount /cdrom' as root.  The CD-ROM
56 will be available under /cdrom/.  Remember to do 'umount /cdrom' before
57 removing the CD-ROM (it will usually not be possible to remove the CD-ROM
58 without doing this.)
59
60 Note: This tip may not work in all configurations.
61 %
62 If you need a reminder to leave your terminal, type "leave +hhmm" where
63 "hhmm" represents in how many hours and minutes you need to leave.
64                 -- Dru <genesis@istar.ca>
65 %
66 If you need to ask a question on the FreeBSD-questions mailing list then
67
68         https://www.FreeBSD.org/doc/en_US.ISO8859-1/articles/\
69                 freebsd-questions/index.html
70
71 contains lots of useful advice to help you get the best results.
72 %
73 If you write part of a filename in tcsh,
74 pressing TAB will show you the available choices when there
75 is more than one, or complete the filename if there's only one match.
76 %
77 If you `set watch = (0 any any)' in tcsh, you will be notified when
78 someone logs in or out of your system.
79 %
80 If you use the C shell, add the following line to the .cshrc file in your
81 home directory to prevent core files from being written to disk:
82
83         limit coredumpsize 0
84                 -- Dru <genesis@istar.ca>
85 %
86 If you want df(1) and other commands to display disk sizes in
87 kilobytes instead of 512-byte blocks, set BLOCKSIZE in your
88 environment to 'K'.  You can also use 'M' for Megabytes or 'G' for
89 Gigabytes.  If you want df(1) to automatically select the best size
90 then use 'df -h'.
91 %
92 If you want to play CDs with FreeBSD, a utility for this is already included.
93 Type 'cdcontrol' then 'help' to learn more.  (You may need to set the CDROM
94 environment variable in order to make cdcontrol want to start.)
95 %
96 If you'd like to keep track of applications in the FreeBSD ports tree, take a
97 look at FreshPorts;
98
99         https://www.freshports.org/
100 %
101 In order to make fetch (the FreeBSD downloading tool) ask for
102 username/password when it encounters a password-protected web page, you can set
103 the environment variable HTTP_AUTH to 'basic:*'.
104 %
105 In order to search for a string in some files, use 'grep' like this:
106
107          grep "string" filename1 [filename2 filename3 ...]
108
109 This will print out the lines in the files that contain the string.  grep can
110 also do a lot more advanced searches - type 'man grep' for details.
111 %
112 In order to support national characters for European languages in tools like
113 less without creating other nationalisation aspects, set the environment
114 variable LC_ALL to 'en_US.UTF-8'.
115 %
116 "man firewall" will give advice for building a FreeBSD firewall using ipfw(8).
117                 -- David Scheidt <dscheidt@tumbolia.com>
118 %
119 "man hier" will explain the way FreeBSD filesystems are normally laid out.
120                 -- David Scheidt <dscheidt@tumbolia.com>
121 %
122 Man pages are divided into section depending on topic.  There are 9 different
123 sections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual).
124 You can get an introduction to each topic by typing
125
126         man <number> intro
127
128 In other words, to get the intro to general commands, type
129
130         man 1 intro
131 %
132 "man ports" gives many useful hints about installing FreeBSD ports.
133 %
134 "man security" gives very good advice on how to tune the security of your
135 FreeBSD system.
136 %
137 "man tuning" gives some tips how to tune performance of your FreeBSD system.
138                 -- David Scheidt <dscheidt@tumbolia.com>
139 %
140 Need to do a search in a manpage or in a file you've sent to a pager? Use
141 "/search_word". To repeat the same search, type "n" for next or "p" for
142 previous.
143                 -- Dru <genesis@istar.ca>
144 %
145 Need to find the location of a program? Use "locate program_name".
146                 -- Dru <genesis@istar.ca>
147 %
148 Need to leave your terminal for a few minutes and don't want to logout?
149 Use "lock -p". When you return, use your password as the key to unlock the
150 terminal.
151                 -- Dru <genesis@istar.ca>
152 %
153 Need to quickly empty a file? Use ": > filename".
154                 -- Dru <genesis@istar.ca>
155 %
156 Need to quickly return to your home directory? Type "cd".
157                 -- Dru <genesis@istar.ca>
158 %
159 Need to remove all those ^M characters from a DOS file? Try
160
161         tr -d \\r < dosfile > newfile
162                 -- Originally by Dru <genesis@istar.ca>
163 %
164 Need to see the calendar for this month? Simply type "cal".  To see the
165 whole year, type "cal -y".
166                 -- Dru <genesis@istar.ca>
167 %
168 Need to see which daemons are listening for connection requests? Use
169 "sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6.
170                 -- Dru <genesis@istar.ca>
171 %
172 Need to see your routing table? Type "netstat -rn". The entry with the G
173 flag is your gateway.
174                 -- Dru <genesis@istar.ca>
175 %
176 Nice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
177                 -- Mathieu <mathieu@hal.interactionvirtuelle.com>
178 %
179 Over quota?  "du -sh * | sort -h " will give you a sorted list of your
180 directory sizes.
181                 -- David Scheidt <dscheidt@tumbolia.com>
182 %
183 nc(1) (or netcat) is useful not only for redirecting input/output to
184 TCP or UDP connections, but also for proxying them with inetd(8).
185 %
186 sh (the default Bourne shell in FreeBSD) supports command-line editing.  Just
187 ``set -o emacs'' or ``set -o vi'' to enable it. Use "<TAB>" key to complete
188 paths.
189 %
190 Simple tcsh prompt: set prompt = '%# '
191 %
192 The default editor in FreeBSD is vi, which is efficient to use when you have
193 learned it, but somewhat user-unfriendly.  To use ee (an easier but less
194 powerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
195 %
196 Time to change your password? Type "passwd" and follow the prompts.
197                 -- Dru <genesis@istar.ca>
198 %
199 To change an environment variable in /bin/sh use:
200
201         $ VARIABLE="value"
202         $ export VARIABLE
203 %
204 To change an environment variable in tcsh you use: setenv NAME "value"
205 where NAME is the name of the variable and "value" its new value.
206 %
207 To clear the screen, use "clear". To re-display your screen buffer, press
208 the scroll lock key and use your page up button. When you're finished,
209 press the scroll lock key again to get your prompt back.
210                 -- Dru <genesis@istar.ca>
211 %
212 You can press Ctrl-L while in the shell to clear the screen.
213 %
214 To determine whether a file is a text file, executable, or some other type
215 of file, use
216
217         file filename
218                 -- Dru <genesis@istar.ca>
219 %
220 To do a fast search for a file, try
221
222          locate filename
223
224 locate uses a database that is updated every Saturday (assuming your computer
225 is running FreeBSD at the time) to quickly find files based on name only.
226 %
227 To erase a line you've written at the command prompt, use "Ctrl-U".
228                 -- Dru <genesis@istar.ca>
229 %
230 To find out the hostname associated with an IP address, use
231
232         drill -x IP_address
233                 -- Dru <genesis@istar.ca>
234 %
235 To obtain a neat PostScript rendering of a manual page, use ``-t'' switch
236 of the man(1) utility: ``man -t <topic>''.  For example:
237
238         man -t grep > grep.ps   # Save the PostScript version to a file
239 or
240         man -t printf | lp      # Send the PostScript directly to printer
241 %
242 To quickly create an empty file, use "touch filename".
243                 -- Dru <genesis@istar.ca>
244 %
245 To read a compressed file without having to first uncompress it, use
246 "zcat" or "zless" to view it. There is also "bzcat", "bzless", "xzcat"
247 and "xzless".
248                 -- Dru <genesis@istar.ca>
249 %
250 To save disk space in your home directory, compress files you rarely
251 use with "gzip filename".
252                 -- Dru <genesis@istar.ca>
253 %
254 To search for files that match a particular name, use find(1); for example
255
256         find / -name "*GENERIC*" -ls
257
258 will search '/', and all subdirectories, for files with 'GENERIC' in the name.
259         --  Stephen Hilton <nospam@hiltonbsd.com>
260 %
261 To see all of the directories on your FreeBSD system, type
262
263         find / -type d | less
264
265 All the files?
266
267         find / -type f | less
268 %
269 To see how long it takes a command to run, type the word "time" before the
270 command name.
271                 -- Dru <genesis@istar.ca>
272 %
273 To see how much disk space is left on your UFS partitions, use
274
275         df -h
276                 -- Dru <genesis@istar.ca>
277 %
278 To see the 10 largest files on a directory or UFS partition, use
279
280         du -h /partition_or_directory_name | sort -rh | head
281                 -- Dru <genesis@istar.ca>
282 %
283 To see the IP addresses currently set on your active interfaces, type
284 "ifconfig -u".
285                 -- Dru <genesis@istar.ca>
286 %
287 To see the last 10 lines of a long file, use "tail filename". To see the
288 first 10 lines, use "head filename". To see new lines as they're appended
289 to a file, use "tail -f filename".
290                 -- Dru <genesis@istar.ca>
291 %
292 To see the last time that you logged in, use lastlogin(8).
293                 -- Dru <genesis@istar.ca>
294 %
295 To see the MAC addresses of the NICs on your system, type
296
297         ifconfig -a
298                 -- Dru <genesis@istar.ca>
299 %
300 To see the output from when your computer started, run dmesg(8).  If it has
301 been replaced with other messages, look at /var/run/dmesg.boot.
302                 -- Francisco Reyes <lists@natserv.com>
303 %
304 Want colour in your directory listings?  Use "ls -G".  "ls -F" is also useful,
305 and they can be combined as "ls -FG".
306 %
307 Want to find a specific port, just type the following under /usr/ports
308 or one its subdirectories:
309
310         make search name=<port-name>
311     or
312         make search key=<keyword>
313 %
314 Want to know how many words, lines, or bytes are contained in a file? Type
315 "wc filename".
316                 -- Dru <genesis@istar.ca>
317 %
318 Want to see how much virtual memory you're using? Just type "swapinfo" to
319 be shown information about the usage of your swap partitions.
320 %
321 Want to strip UTF-8 BOM(Byte Order Mark) from given files?
322
323         sed -e '1s/^\xef\xbb\xbf//' < bomfile > newfile
324 %
325 Want to use sed(1) to edit a file in place?  Well, to replace every 'e' with
326 an 'o', in a file named 'foo', you can do:
327
328         sed -i.bak s/e/o/g foo
329
330 And you'll get a backup of the original in a file named 'foo.bak', but if you
331 want no backup:
332
333         sed -i '' s/e/o/g foo
334 %
335 When you've made modifications to a file in vi(1) and then find that
336 you can't write it, type ``<ESC>!rm -f %'' then ``:w!'' to force the
337 write
338
339 This won't work if you don't have write permissions to the directory
340 and probably won't be suitable if you're editing through a symbolic link.
341
342 If you have sudo(8) installed and permissions to use it, type 
343 ``<ESC>w ! sudo tee %'' to force a write.
344 %
345 You can adjust the volume of various parts of the sound system in your
346 computer by typing 'mixer <type> <volume>'.  To get a list of what you can
347 adjust, just type 'mixer'.
348 %
349 You can automatically download and install binary packages by doing
350
351         pkg install <package>
352
353 This will also automatically install the packages that are dependencies
354 for the package you install (ie, the packages it needs in order to work.)
355 %
356 You can change the video mode on all consoles by adding something like
357 the following to /etc/rc.conf:
358
359         allscreens="80x30"
360
361 You can use "vidcontrol -i mode | grep T" for a list of supported text
362 modes.
363                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
364 %
365 You can disable tcsh's terminal beep if you `set nobeep'.
366 %
367 You can install extra packages for FreeBSD by using the ports system.
368 If you have installed it, you can download, compile, and install software by
369 just typing
370
371         # cd /usr/ports/<category>/<portname>
372         # make install && make clean
373
374 as root.  The ports infrastructure will download the software, change it so
375 it works on FreeBSD, compile it, install it, register the installation so it
376 will be possible to automatically uninstall it, and clean out the temporary
377 working space it used.  You can remove an installed port you decide you do not
378 want after all by typing
379
380         # cd /usr/ports/<category>/<portname>
381         # make deinstall
382
383 as root.
384 %
385 You can look through a file in a nice text-based interface by typing
386
387         less filename
388 %
389 You can make a log of your terminal session with script(1).
390 %
391 You can often get answers to your questions about FreeBSD by searching in the
392 FreeBSD mailing list archives at
393
394         http://freebsd.markmail.org
395 %
396 You can open up a new split-screen window in (n)vi with :N or :E and then
397 use ^w to switch between the two.
398 %
399 You can permanently set environment variables for your shell by putting them
400 in a startup file for the shell.  The name of the startup file varies
401 depending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use
402 .profile.  When using bash, sh, ksh or zsh, don't forget to export the
403 variable.
404 %
405 You can press Ctrl-D to quickly exit from a shell, or logout from a
406 login shell.
407                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
408 %
409 You can press up-arrow or down-arrow to walk through a list of
410 previous commands in tcsh.
411 %
412 You can search for documentation on a keyword by typing
413
414         apropos keyword
415 %
416 You can `set autologout = 30' to have tcsh log you off automatically
417 if you leave the shell idle for more than 30 minutes.
418 %
419 You can use aliases to decrease the amount of typing you need to do to get
420 commands you commonly use.  Examples of fairly popular aliases include (in
421 Bourne shell style, as in /bin/sh, bash, ksh, and zsh):
422
423         alias lf="ls -FA"
424         alias ll="ls -lA"
425         alias su="su -m"
426
427 In csh or tcsh, these would be
428
429         alias lf ls -FA
430         alias ll ls -lA
431         alias su su -m
432
433 To remove an alias, you can usually use 'unalias aliasname'.  To list all
434 aliases, you can usually type just 'alias'.
435 %
436 You can use /etc/make.conf to control the options used to compile software
437 on this system.  Example entries are in
438 /usr/share/examples/etc/make.conf and in make.conf(5).
439 For options that are set for building FreeBSD's kernel and its world, see
440 src.conf(5).
441 %
442 You can use "pkg info" to see a list of packages you have installed.
443 %
444 You can use the 'fetch' command to retrieve files over ftp, http or https.
445
446          fetch https://www.FreeBSD.org/index.html
447
448 will download the front page of the FreeBSD web site.
449 %
450 You can use "whereis" to search standard binary, manual page and source
451 directories for the specified programs. This can be particularly handy
452 when you are trying to find where in the ports tree an application is.
453
454 Try "whereis firefox" and "whereis whereis".
455                 -- Konstantinos Konstantinidis <kkonstan@duth.gr>
456 %
457 Want to run the same command again?
458 In many shells (e.g., tcsh, zsh, bash) you can type "!!".
459 %
460 Want to go the directory you were just in?
461 Type "cd -"
462 %
463 Can't delete /usr/obj? Enter "chflags -R noschg /usr/obj" to remove the
464 system immutable flag for all files in /usr/obj.
465
466                 -- Lars Engels <lme@FreeBSD.org>
467 %
468 Want to list all files of an installed package? Enter
469 "pkg info -l packagename".
470
471                 -- Lars Engels <lme@FreeBSD.org>
472 %
473 Are you looking for a package? Search for it with
474 "pkg search part_of_package_name"
475
476                 -- Lars Engels <lme@FreeBSD.org>
477 %
478 If you want to recursively copy a directory preserving file and directory
479 attributes use
480 "cp -a source target"
481
482                 -- Lars Engels <lme@FreeBSD.org>
483 %
484 Do you wonder what a terminal program is doing at the moment? dd(1) does not
485 show any throughput? Hit "^T" (Control + t) to send SIGINFO to the process
486 and see what it is doing.
487
488                 -- Lars Engels <lme@FreeBSD.org>
489 %
490 Do you want to know which version of FreeBSD you are running? Enter
491 "freebsd-version -ku" to display kernel and userland version.
492
493                 -- Lars Engels <lme@FreeBSD.org>
494 %
495 If you want to end one or more processes at a time using a regular expression
496 enter "pkill regex".
497
498                 -- Lars Engels <lme@FreeBSD.org>
499 %
500 Do you want to run a program directly after some other process has ended? Use
501 "pwait pid && new_program"
502
503                 -- Lars Engels <lme@FreeBSD.org>
504 %
505 When you want your users to be able to reboot or shutdown FreeBSD, add them
506 to the group "operator" and they are allowed to use shutdown(8) and poweroff(8).
507
508                 -- Lars Engels <lme@FreeBSD.org>
509 %
510 If you need to create a FAT32 formatted USB thumb drive, find out its devicename
511 running dmesg(8) after inserting it. Then create an MBR schema, a single slice and
512 format it:
513
514 # gpart create -s MBR ${devicename}
515 # gpart add -t fat32 ${devicename}
516 # newfs_msdos -F 32 -L thumbdrive ${devicename}s1
517
518                 -- Lars Engels <lme@FreeBSD.org>
519 %
520 If you want to get a sorted list of all services that are started when FreeBSD boots,
521 enter "service -e".
522
523                 -- Lars Engels <lme@FreeBSD.org>
524 %
525 To easily configure your installed FreeBSD use bsdconfig(8).
526
527                 -- Lars Engels <lme@FreeBSD.org>
528 %
529 After you compiled and installed a new version of FreeBSD, use etcupdate(8) to merge
530 configuration updates.
531 Run "etcupdate extract" once when your sources match your running system, then run
532 "etcupdate" after every upgrade and "etcupdate resolve" to resolve any conflicts.
533
534                 -- Lars Engels <lme@FreeBSD.org>
535 %
536 Do you want to do a binary upgrade of your running FreeBSD installation? Use freebsd-update(8).
537
538 To install updates and patches for the running branch use
539 # freebsd-update fetch install
540
541 To upgrade to a newer release use
542 # freebsd-update upgrade -r ${name_of_release}
543
544                 -- Lars Engels <lme@FreeBSD.org>
545 %
546 To run rc scripts in /etc/rc.d and /usr/local/etc/rc.d use service(8).
547 Run "service ${name_of_rc_script} start" to start a daemon and
548 "service ${name_of_rc_script} stop" to stop it.
549
550                 -- Lars Engels <lme@FreeBSD.org>
551 %
552 If you don't want to edit /etc/rc.conf directly, use sysrc(8) to add and remove entries.
553 Use "sysrc name=value" to add an entry and "sysrc -x name" to delete an entry.
554
555                 -- Lars Engels <lme@FreeBSD.org>
556 %
557 You can upload the dmesg of your system to help developers get an overview of commonly
558 used hardware and peripherals for FreeBSD. Use the curl package to upload it like this:
559 curl -v -d "nickname=$USER" -d "description=FreeBSD/$(uname -m) on \
560 $(kenv smbios.system.maker) $(kenv smbios.system.product)" -d "do=addd" \
561 --data-urlencode 'dmesg@/var/run/dmesg.boot' http://dmesgd.nycbug.org/index.cgi
562 %
563 Want to know how much memory (in bytes) your machine has available? Let
564 sysctl(8) tell you with the following command:
565
566 sysctl hw.physmem
567
568 The number of active CPUs is displayed using this command:
569
570 sysctl hw.ncpu
571
572                 -- Benedict Reuschling <bcr@FreeBSD.org>
573 %
574 When using ZFS as the file system the "df" command will display confusing 
575 values. Use the built-in "zfs list" command to get an overview of space usage:
576
577 zfs list -o space
578
579                 -- Benedict Reuschling <bcr@FreeBSD.org>
580 %
581 To learn more about what your system is doing, take a look at systat(1). For
582 example, to get an overview of I/O happening in the system, run:
583
584 systat -iostat
585
586 Other values are icmp, icmp6, ifstat, ip, ip6, netstat, pigs, sctp, swap, tcp,
587 vmstat, or zarc. You can switch between displays using :<display> and exit
588 back to your shell by typing
589
590 :quit
591
592                 -- Benedict Reuschling <bcr@FreeBSD.org>
593 %
594 To set a quota of 10 GB for the user named foo on a ZFS dataset, run the
595 following command:
596
597 # zfs set userquota@foo=10G pool/home/foo
598
599 The zfs userspace command can display the quota and current space usage:
600
601 # zfs userspace pool/home/foo
602
603 To unset a quota, assign "none" as the value. 
604                 -- Benedict Reuschling <bcr@FreeBSD.org>
605 %
606 ZFS can display I/O statistics for a given pool using the iostat subcommand.
607 By default, it will display one line of current activity.  To display stats
608 every 5 seconds run the following command (cancel with CTRL+C):
609
610 zpool iostat 5
611
612 To view individual disk activities, specify the -v parameter:
613
614 zpool iostat -v
615
616 Of course, both can be combined. For more options, see zpool(8).
617                 -- Benedict Reuschling <bcr@FreeBSD.org>
618 %
619 FreeBSD's top(1) utility displays CPU statistics by default.
620 To display I/O activity for each process instead, run top like this:
621
622 top -m io
623
624                 -- Benedict Reuschling <bcr@FreeBSD.org>
625 %
626 ZFS keeps a history of commands run against a specific pool using the
627 history subcommand to zpool:
628
629 zpool history
630
631 More details are available using the -i and -l parameters. Note that ZFS
632 will not keep the complete pool history forever and will remove older
633 events in favor of never ones.
634                 -- Benedict Reuschling <bcr@FreeBSD.org>
635 %
636 To display the compression ratio for the ZFS dataset /var/log on the pool
637 mypool, run the following command:
638
639 zfs get refcompressratio mypool/var/log
640
641 The refcompressratio will only display the compression ratio for that specific
642 dataset, not the descendant datasets. To include the child datasets, the
643 command looks like this:
644
645 zfs get compressratio mypool/var
646
647                 -- Benedict Reuschling <bcr@FreeBSD.org>
648 %
649 You can limit the depth of the displayed datasets in the "zfs list" output
650 using the -d parameter. To display only the first level of datasets below
651 mypool/usr and not the ones deeper than those, run this command:
652
653 zfs list -d 1 mypool/usr
654
655                 -- Benedict Reuschling <bcr@FreeBSD.org>
656 %
657 The "zfs list" command can be filtered in multiple ways. To display just
658 the dataset name, use the -o parameter:
659
660 zfs list -o name mypool/usr
661
662 More columns and their order can be defined by separating them with commas:
663
664 zfs list -o mountpoint,name,avail
665
666                 -- Benedict Reuschling <bcr@FreeBSD.org>
667 %
668 The output of "zfs list" can be sorted by a specific column using -s.  To
669 sort the datasets by the "used" column in ascending order, run this command:
670
671 zfs list -s used
672
673 To sort in descending order instead, use -S:
674
675 zfs list -S used
676
677                 -- Benedict Reuschling <bcr@FreeBSD.org>
678 %
679 To make the "zfs list" output more script-friendly, you can suppress the
680 output of the headers for each column by passing the -H parameter:
681
682 zfs list -H
683
684 Another helpful option for script writers is -p, which displays the numbers
685 in non-rounded, exact values:
686
687 zfs list -p 
688
689                 -- Benedict Reuschling <bcr@FreeBSD.org>
690 %
691 Before deleting a dataset or snapshot, perform a dry run using the -n
692 parameter. This is to make sure you really want to delete just that
693 dataset/snapshot and not any dependent ones. ZFS will display the resulting
694 action when -n is combined with the -v option without actually performing
695 it:
696
697 zfs destroy -rvn mypool@mysnap
698
699 Once you are sure this is exactly what you intend to do, remove the -n
700 parameter to execute the destroy operation.
701                 -- Benedict Reuschling <bcr@FreeBSD.org>
702 %
703 You can delete a range of ZFS snapshots (a-z) in multiple ways.
704 The following will delete d and all earlier snapshots: 
705
706 zfs destroy mypool/data@%d
707
708 To delete d and all later snapshots:
709
710 zfs destroy mypool/data@d%
711
712 To delete all dataset snapshots:
713
714 zfs destroy mypool/data@%
715
716 Make sure to let ZFS perform a dry run (-n option) first and display (-v) what
717 it would do to confirm that the delete operation is removing exactly what you 
718 intended. 
719                 -- Benedict Reuschling <bcr@FreeBSD.org>
720 %
721 To set a custom ZFS property on the mypool pool, you need to provide it
722 using the "key1:key2=value" syntax, where the colon (:) is used as the
723 separator and identifier from the built-in ZFS properties:
724
725 # zfs set warranty:expires=2038-01-19 mypool
726
727 The custom property is applied to all datasets and can be queried like any
728 built-in properties using zfs get:
729
730 zfs get warranty:expires mypool
731
732 To reset the value of a custom property, use the inherit subcommand:
733
734 # zfs inherit warranty:expires mypool
735
736 Removing a custom property from a pool is done using the -r flag to the
737 "zfs inherit" command:
738
739 # zfs inherit -r warranty:expires mypool
740
741                 -- Benedict Reuschling <bcr@FreeBSD.org>
742 %
743 To delete a range of ZFS snapshots, use the % (percent) character after the
744 full path to the first snapshot that should be included. For example, to
745 simulate deleting snapshots a through (including) d, use this command:
746
747 # zfs destroy -rvn mypool/tmp@a%d
748
749 Once you are sure that this is what you want, remove the -n option:
750
751 # zfs destroy -rv mypool/tmp@a%d
752
753                 -- Benedict Reuschling <bcr@FreeBSD.org>
754 %
755 You can prevent the removal of a ZFS snapshot by using the hold subcommand.
756 For example, to prevent the snapshot called milestone from deletion, run the
757 following command:
758
759 # zfs hold milestone_hold mypool/projects@my_milestone
760
761 The "zfs holds" command will list all current snapshots that are protected
762 this way (-r for a recursive list):
763
764 # zfs holds -r mypool
765
766 The TIMESTAMP column in the output of the above command is from when the
767 hold was created, not the snapshot it holds. The "zfs destroy" command will
768 echo a "dataset is busy" message on the console when it encounters a hold.
769 Use "zfs release" to release the hold on the snapshot:
770
771 # zfs release milestone_hold mypool/projects@my_milestone
772
773                 -- Benedict Reuschling <bcr@FreeBSD.org>
774 %
775 A user "sender" needs the following permissions set to send a ZFS dataset:
776
777 # zfs allow -u sender send,snapshot txpool
778
779 On the receiving side, the user "receiver" requires these permissions:
780
781 # zfs allow -u receiver compression,mountpoint,mount,create,receive rxpool
782
783                 -- Benedict Reuschling <bcr@FreeBSD.org>
784 %
785 Don't let your zpool fill up completely by creating a dataset with
786 reservation.
787
788 # zfs create -o refreservation=<5% of total pool space> <poolname>/reserved
789
790 You can always shrink the reserve if you need the space, but your pool will
791 always have space left this way.
792
793                 -- Benedict Reuschling <bcr@FreeBSD.org>
794 %