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