xref: /freebsd/usr.bin/fortune/datfiles/freebsd-tips (revision a9ea96eafd9f3144f297cc5420bbfde0471f4bc4)
16ae1554aSColin PercivalThis fortune brought to you by:
26ae1554aSColin Percival$FreeBSD$
36ae1554aSColin Percival%
46ae1554aSColin PercivalAny user that is a member of the wheel group can use "su -" to simulate
56ae1554aSColin Percivala root login. You can add a user to the wheel group by editing /etc/group.
66ae1554aSColin Percival		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
76ae1554aSColin Percival%
86ae1554aSColin PercivalBy pressing "Scroll Lock" you can use the arrow keys to scroll backward
96ae1554aSColin Percivalthrough the console output.  Press "Scroll Lock" again to turn it off.
101909a1f4SAlfred PerlsteinDon't have a "Scroll Lock" key? The "Pause / Break" key acts alike.
116ae1554aSColin Percival%
126ae1554aSColin PercivalCan't remember if you've installed a certain port or not? Try "pkg info
136ae1554aSColin Percival-x port_name".
146ae1554aSColin Percival%
156ae1554aSColin PercivalEver wonder what those numbers after command names were, as in cat(1)?  It's
166ae1554aSColin Percivalthe section of the manual the man page is in.  "man man" will tell you more.
176ae1554aSColin Percival		-- David Scheidt <dscheidt@tumbolia.com>
186ae1554aSColin Percival%
196ae1554aSColin PercivalForget how to spell a word or a variation of a word? Use
206ae1554aSColin Percival
216ae1554aSColin Percival	look portion_of_word_you_know
226ae1554aSColin Percival		-- Dru <genesis@istar.ca>
236ae1554aSColin Percival%
246ae1554aSColin PercivalForget what directory you are in? Type "pwd".
256ae1554aSColin Percival		-- Dru <genesis@istar.ca>
266ae1554aSColin Percival%
276ae1554aSColin PercivalForget when Easter is? Try "ncal -e". If you need the date for Orthodox
286ae1554aSColin PercivalEaster, use "ncal -o" instead.
296ae1554aSColin Percival		-- Dru <genesis@istar.ca>
306ae1554aSColin Percival%
316ae1554aSColin PercivalFreeBSD is started up by the program 'init'.  The first thing init does when
326ae1554aSColin Percivalstarting multiuser mode (ie, starting the computer up for normal use) is to
336ae1554aSColin Percivalrun the shell script /etc/rc.  By reading /etc/rc and the /etc/rc.d/ scripts,
346ae1554aSColin Percivalyou can learn a lot about how the system is put together, which again will
356ae1554aSColin Percivalmake you more confident about what happens when you do something with it.
366ae1554aSColin Percival%
376ae1554aSColin PercivalHandy bash(1) prompt:  PS1="\u@\h \w \!$ "
386ae1554aSColin Percival		-- David Scheidt <dscheidt@tumbolia.com>
396ae1554aSColin Percival%
406ae1554aSColin PercivalHaving trouble using fetch through a firewall? Try setting the environment
416ae1554aSColin Percivalvariable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details.
426ae1554aSColin Percival%
436ae1554aSColin PercivalIf other operating systems have damaged your Master Boot Record, you can
441909a1f4SAlfred Perlsteinreinstall it with gpart(8). See
451909a1f4SAlfred Perlstein"man gpart" for details.
466ae1554aSColin Percival%
476ae1554aSColin PercivalIf you accidentally end up inside vi, you can quit it by pressing Escape, colon
486ae1554aSColin Percival(:), q (q), bang (!) and pressing return.
496ae1554aSColin Percival%
506ae1554aSColin PercivalIf you do not want to get beeps in X11 (X Windows), you can turn them off with
516ae1554aSColin Percival
526ae1554aSColin Percival	xset b off
536ae1554aSColin Percival%
546ae1554aSColin PercivalIf you have a CD-ROM drive in your machine, you can make the CD-ROM that is
556ae1554aSColin Percivalpresently inserted available by typing 'mount /cdrom' as root.  The CD-ROM
566ae1554aSColin Percivalwill be available under /cdrom/.  Remember to do 'umount /cdrom' before
576ae1554aSColin Percivalremoving the CD-ROM (it will usually not be possible to remove the CD-ROM
586ae1554aSColin Percivalwithout doing this.)
596ae1554aSColin Percival
606ae1554aSColin PercivalNote: This tip may not work in all configurations.
616ae1554aSColin Percival%
626ae1554aSColin PercivalIf you need a reminder to leave your terminal, type "leave +hhmm" where
636ae1554aSColin Percival"hhmm" represents in how many hours and minutes you need to leave.
646ae1554aSColin Percival		-- Dru <genesis@istar.ca>
656ae1554aSColin Percival%
666ae1554aSColin PercivalIf you need to ask a question on the FreeBSD-questions mailing list then
676ae1554aSColin Percival
687e3f9a34SEitan Adler	https://www.FreeBSD.org/doc/en_US.ISO8859-1/articles/\
696ae1554aSColin Percival		freebsd-questions/index.html
706ae1554aSColin Percival
716ae1554aSColin Percivalcontains lots of useful advice to help you get the best results.
726ae1554aSColin Percival%
736ae1554aSColin PercivalIf you write part of a filename in tcsh,
746ae1554aSColin Percivalpressing TAB will show you the available choices when there
756ae1554aSColin Percivalis more than one, or complete the filename if there's only one match.
766ae1554aSColin Percival%
776ae1554aSColin PercivalIf you `set watch = (0 any any)' in tcsh, you will be notified when
786ae1554aSColin Percivalsomeone logs in or out of your system.
796ae1554aSColin Percival%
806ae1554aSColin PercivalIf you use the C shell, add the following line to the .cshrc file in your
816ae1554aSColin Percivalhome directory to prevent core files from being written to disk:
826ae1554aSColin Percival
836ae1554aSColin Percival	limit coredumpsize 0
846ae1554aSColin Percival		-- Dru <genesis@istar.ca>
856ae1554aSColin Percival%
866ae1554aSColin PercivalIf you want df(1) and other commands to display disk sizes in
876ae1554aSColin Percivalkilobytes instead of 512-byte blocks, set BLOCKSIZE in your
886ae1554aSColin Percivalenvironment to 'K'.  You can also use 'M' for Megabytes or 'G' for
896ae1554aSColin PercivalGigabytes.  If you want df(1) to automatically select the best size
906ae1554aSColin Percivalthen use 'df -h'.
916ae1554aSColin Percival%
926ae1554aSColin PercivalIf you want to play CDs with FreeBSD, a utility for this is already included.
936ae1554aSColin PercivalType 'cdcontrol' then 'help' to learn more.  (You may need to set the CDROM
946ae1554aSColin Percivalenvironment variable in order to make cdcontrol want to start.)
956ae1554aSColin Percival%
966ae1554aSColin PercivalIf you'd like to keep track of applications in the FreeBSD ports tree, take a
976ae1554aSColin Percivallook at FreshPorts;
986ae1554aSColin Percival
997e3f9a34SEitan Adler	https://www.freshports.org/
1006ae1554aSColin Percival%
1016ae1554aSColin PercivalIn order to make fetch (the FreeBSD downloading tool) ask for
1026ae1554aSColin Percivalusername/password when it encounters a password-protected web page, you can set
1036ae1554aSColin Percivalthe environment variable HTTP_AUTH to 'basic:*'.
1046ae1554aSColin Percival%
1056ae1554aSColin PercivalIn order to search for a string in some files, use 'grep' like this:
1066ae1554aSColin Percival
1076ae1554aSColin Percival	 grep "string" filename1 [filename2 filename3 ...]
1086ae1554aSColin Percival
1096ae1554aSColin PercivalThis will print out the lines in the files that contain the string.  grep can
1106ae1554aSColin Percivalalso do a lot more advanced searches - type 'man grep' for details.
1116ae1554aSColin Percival%
1126ae1554aSColin PercivalIn order to support national characters for European languages in tools like
1136ae1554aSColin Percivalless without creating other nationalisation aspects, set the environment
114ff744dbdSEitan Adlervariable LC_ALL to 'en_US.UTF-8'.
1156ae1554aSColin Percival%
1161909a1f4SAlfred Perlstein"man firewall" will give advice for building a FreeBSD firewall using ipfw(8).
1176ae1554aSColin Percival		-- David Scheidt <dscheidt@tumbolia.com>
1186ae1554aSColin Percival%
1196ae1554aSColin Percival"man hier" will explain the way FreeBSD filesystems are normally laid out.
1206ae1554aSColin Percival		-- David Scheidt <dscheidt@tumbolia.com>
1216ae1554aSColin Percival%
1226ae1554aSColin PercivalMan pages are divided into section depending on topic.  There are 9 different
1236ae1554aSColin Percivalsections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual).
1246ae1554aSColin PercivalYou can get an introduction to each topic by typing
1256ae1554aSColin Percival
1266ae1554aSColin Percival	man <number> intro
1276ae1554aSColin Percival
1286ae1554aSColin PercivalIn other words, to get the intro to general commands, type
1296ae1554aSColin Percival
1306ae1554aSColin Percival	man 1 intro
1316ae1554aSColin Percival%
1326ae1554aSColin Percival"man ports" gives many useful hints about installing FreeBSD ports.
1336ae1554aSColin Percival%
1346ae1554aSColin Percival"man security" gives very good advice on how to tune the security of your
1356ae1554aSColin PercivalFreeBSD system.
1366ae1554aSColin Percival%
1376ae1554aSColin Percival"man tuning" gives some tips how to tune performance of your FreeBSD system.
1386ae1554aSColin Percival		-- David Scheidt <dscheidt@tumbolia.com>
1396ae1554aSColin Percival%
1406ae1554aSColin PercivalNeed to do a search in a manpage or in a file you've sent to a pager? Use
1411909a1f4SAlfred Perlstein"/search_word". To repeat the same search, type "n" for next or "p" for
1421909a1f4SAlfred Perlsteinprevious.
1436ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1446ae1554aSColin Percival%
1456ae1554aSColin PercivalNeed to find the location of a program? Use "locate program_name".
1466ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1476ae1554aSColin Percival%
1486ae1554aSColin PercivalNeed to leave your terminal for a few minutes and don't want to logout?
1496ae1554aSColin PercivalUse "lock -p". When you return, use your password as the key to unlock the
1506ae1554aSColin Percivalterminal.
1516ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1526ae1554aSColin Percival%
1536ae1554aSColin PercivalNeed to quickly empty a file? Use ": > filename".
1546ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1556ae1554aSColin Percival%
1566ae1554aSColin PercivalNeed to quickly return to your home directory? Type "cd".
1576ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1586ae1554aSColin Percival%
1596ae1554aSColin PercivalNeed to remove all those ^M characters from a DOS file? Try
1606ae1554aSColin Percival
1616ae1554aSColin Percival	tr -d \\r < dosfile > newfile
1626ae1554aSColin Percival		-- Originally by Dru <genesis@istar.ca>
1636ae1554aSColin Percival%
1646ae1554aSColin PercivalNeed to see the calendar for this month? Simply type "cal".  To see the
1656ae1554aSColin Percivalwhole year, type "cal -y".
1666ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1676ae1554aSColin Percival%
1686ae1554aSColin PercivalNeed to see which daemons are listening for connection requests? Use
1696ae1554aSColin Percival"sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6.
1706ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1716ae1554aSColin Percival%
1726ae1554aSColin PercivalNeed to see your routing table? Type "netstat -rn". The entry with the G
1736ae1554aSColin Percivalflag is your gateway.
1746ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1756ae1554aSColin Percival%
1766ae1554aSColin PercivalNice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ '
1776ae1554aSColin Percival		-- Mathieu <mathieu@hal.interactionvirtuelle.com>
1786ae1554aSColin Percival%
1791909a1f4SAlfred PerlsteinOver quota?  "du -sh * | sort -h " will give you a sorted list of your
1806ae1554aSColin Percivaldirectory sizes.
1816ae1554aSColin Percival		-- David Scheidt <dscheidt@tumbolia.com>
1826ae1554aSColin Percival%
1836ae1554aSColin Percivalnc(1) (or netcat) is useful not only for redirecting input/output to
1846ae1554aSColin PercivalTCP or UDP connections, but also for proxying them with inetd(8).
1856ae1554aSColin Percival%
1866ae1554aSColin Percivalsh (the default Bourne shell in FreeBSD) supports command-line editing.  Just
1871909a1f4SAlfred Perlstein``set -o emacs'' or ``set -o vi'' to enable it. Use "<TAB>" key to complete
1881909a1f4SAlfred Perlsteinpaths.
1896ae1554aSColin Percival%
1906ae1554aSColin PercivalSimple tcsh prompt: set prompt = '%# '
1916ae1554aSColin Percival%
1926ae1554aSColin PercivalThe default editor in FreeBSD is vi, which is efficient to use when you have
1936ae1554aSColin Percivallearned it, but somewhat user-unfriendly.  To use ee (an easier but less
1946ae1554aSColin Percivalpowerful editor) instead, set the environment variable EDITOR to /usr/bin/ee
1956ae1554aSColin Percival%
1966ae1554aSColin PercivalTime to change your password? Type "passwd" and follow the prompts.
1976ae1554aSColin Percival		-- Dru <genesis@istar.ca>
1986ae1554aSColin Percival%
1996ae1554aSColin PercivalTo change an environment variable in /bin/sh use:
2006ae1554aSColin Percival
2016ae1554aSColin Percival	$ VARIABLE="value"
2026ae1554aSColin Percival	$ export VARIABLE
2036ae1554aSColin Percival%
2046ae1554aSColin PercivalTo change an environment variable in tcsh you use: setenv NAME "value"
2056ae1554aSColin Percivalwhere NAME is the name of the variable and "value" its new value.
2066ae1554aSColin Percival%
2076ae1554aSColin PercivalTo clear the screen, use "clear". To re-display your screen buffer, press
2086ae1554aSColin Percivalthe scroll lock key and use your page up button. When you're finished,
2096ae1554aSColin Percivalpress the scroll lock key again to get your prompt back.
2106ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2116ae1554aSColin Percival%
2121909a1f4SAlfred PerlsteinYou can press Ctrl-L while in the shell to clear the screen.
2131909a1f4SAlfred Perlstein%
2146ae1554aSColin PercivalTo determine whether a file is a text file, executable, or some other type
2156ae1554aSColin Percivalof file, use
2166ae1554aSColin Percival
2176ae1554aSColin Percival	file filename
2186ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2196ae1554aSColin Percival%
2206ae1554aSColin PercivalTo do a fast search for a file, try
2216ae1554aSColin Percival
2226ae1554aSColin Percival	 locate filename
2236ae1554aSColin Percival
2246ae1554aSColin Percivallocate uses a database that is updated every Saturday (assuming your computer
2256ae1554aSColin Percivalis running FreeBSD at the time) to quickly find files based on name only.
2266ae1554aSColin Percival%
2276ae1554aSColin PercivalTo erase a line you've written at the command prompt, use "Ctrl-U".
2286ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2296ae1554aSColin Percival%
2301909a1f4SAlfred PerlsteinTo find out the hostname associated with an IP address, use
2316ae1554aSColin Percival
2326ae1554aSColin Percival	drill -x IP_address
2331909a1f4SAlfred Perlstein		-- Dru <genesis@istar.ca>
2346ae1554aSColin Percival%
2356ae1554aSColin PercivalTo obtain a neat PostScript rendering of a manual page, use ``-t'' switch
2366ae1554aSColin Percivalof the man(1) utility: ``man -t <topic>''.  For example:
2376ae1554aSColin Percival
2386ae1554aSColin Percival	man -t grep > grep.ps	# Save the PostScript version to a file
2396ae1554aSColin Percivalor
2406ae1554aSColin Percival	man -t printf | lp	# Send the PostScript directly to printer
2416ae1554aSColin Percival%
2426ae1554aSColin PercivalTo quickly create an empty file, use "touch filename".
2436ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2446ae1554aSColin Percival%
2456ae1554aSColin PercivalTo read a compressed file without having to first uncompress it, use
2461909a1f4SAlfred Perlstein"zcat" or "zless" to view it. There is also "bzcat", "bzless", "xzcat"
2471909a1f4SAlfred Perlsteinand "xzless".
2486ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2496ae1554aSColin Percival%
2506ae1554aSColin PercivalTo save disk space in your home directory, compress files you rarely
2516ae1554aSColin Percivaluse with "gzip filename".
2526ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2536ae1554aSColin Percival%
2546ae1554aSColin PercivalTo search for files that match a particular name, use find(1); for example
2556ae1554aSColin Percival
2566ae1554aSColin Percival	find / -name "*GENERIC*" -ls
2576ae1554aSColin Percival
2586ae1554aSColin Percivalwill search '/', and all subdirectories, for files with 'GENERIC' in the name.
2596ae1554aSColin Percival      	--  Stephen Hilton <nospam@hiltonbsd.com>
2606ae1554aSColin Percival%
2616ae1554aSColin PercivalTo see all of the directories on your FreeBSD system, type
2626ae1554aSColin Percival
2636ae1554aSColin Percival	find / -type d | less
2646ae1554aSColin Percival
2656ae1554aSColin PercivalAll the files?
2666ae1554aSColin Percival
2676ae1554aSColin Percival	find / -type f | less
2686ae1554aSColin Percival%
2696ae1554aSColin PercivalTo see how long it takes a command to run, type the word "time" before the
2706ae1554aSColin Percivalcommand name.
2716ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2726ae1554aSColin Percival%
27356d417fdSBenedict ReuschlingTo see how much disk space is left on your UFS partitions, use
2746ae1554aSColin Percival
2756ae1554aSColin Percival	df -h
2766ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2776ae1554aSColin Percival%
278*a9ea96eaSBenedict ReuschlingTo see the 10 largest files in a directory or on a UFS partition, use
2796ae1554aSColin Percival
2801909a1f4SAlfred Perlstein	du -h /partition_or_directory_name | sort -rh | head
2816ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2826ae1554aSColin Percival%
2836ae1554aSColin PercivalTo see the IP addresses currently set on your active interfaces, type
2846ae1554aSColin Percival"ifconfig -u".
2856ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2866ae1554aSColin Percival%
2876ae1554aSColin PercivalTo see the last 10 lines of a long file, use "tail filename". To see the
2881909a1f4SAlfred Perlsteinfirst 10 lines, use "head filename". To see new lines as they're appended
2891909a1f4SAlfred Perlsteinto a file, use "tail -f filename".
2906ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2916ae1554aSColin Percival%
2926ae1554aSColin PercivalTo see the last time that you logged in, use lastlogin(8).
2936ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2946ae1554aSColin Percival%
2956ae1554aSColin PercivalTo see the MAC addresses of the NICs on your system, type
2966ae1554aSColin Percival
2976ae1554aSColin Percival	ifconfig -a
2986ae1554aSColin Percival		-- Dru <genesis@istar.ca>
2996ae1554aSColin Percival%
3006ae1554aSColin PercivalTo see the output from when your computer started, run dmesg(8).  If it has
3016ae1554aSColin Percivalbeen replaced with other messages, look at /var/run/dmesg.boot.
3026ae1554aSColin Percival		-- Francisco Reyes <lists@natserv.com>
3036ae1554aSColin Percival%
3046ae1554aSColin PercivalWant colour in your directory listings?  Use "ls -G".  "ls -F" is also useful,
3056ae1554aSColin Percivaland they can be combined as "ls -FG".
3066ae1554aSColin Percival%
3076ae1554aSColin PercivalWant to find a specific port, just type the following under /usr/ports
3086ae1554aSColin Percivalor one its subdirectories:
3096ae1554aSColin Percival
3106ae1554aSColin Percival	make search name=<port-name>
3116ae1554aSColin Percival    or
3126ae1554aSColin Percival	make search key=<keyword>
3136ae1554aSColin Percival%
3146ae1554aSColin PercivalWant to know how many words, lines, or bytes are contained in a file? Type
3156ae1554aSColin Percival"wc filename".
3166ae1554aSColin Percival		-- Dru <genesis@istar.ca>
3176ae1554aSColin Percival%
3186ae1554aSColin PercivalWant to see how much virtual memory you're using? Just type "swapinfo" to
3196ae1554aSColin Percivalbe shown information about the usage of your swap partitions.
3206ae1554aSColin Percival%
3216ae1554aSColin PercivalWant to strip UTF-8 BOM(Byte Order Mark) from given files?
3226ae1554aSColin Percival
3236ae1554aSColin Percival	sed -e '1s/^\xef\xbb\xbf//' < bomfile > newfile
3246ae1554aSColin Percival%
3256ae1554aSColin PercivalWant to use sed(1) to edit a file in place?  Well, to replace every 'e' with
3266ae1554aSColin Percivalan 'o', in a file named 'foo', you can do:
3276ae1554aSColin Percival
3286ae1554aSColin Percival	sed -i.bak s/e/o/g foo
3296ae1554aSColin Percival
3306ae1554aSColin PercivalAnd you'll get a backup of the original in a file named 'foo.bak', but if you
3316ae1554aSColin Percivalwant no backup:
3326ae1554aSColin Percival
3336ae1554aSColin Percival	sed -i '' s/e/o/g foo
3346ae1554aSColin Percival%
3356ae1554aSColin PercivalWhen you've made modifications to a file in vi(1) and then find that
3366ae1554aSColin Percivalyou can't write it, type ``<ESC>!rm -f %'' then ``:w!'' to force the
3376ae1554aSColin Percivalwrite
3386ae1554aSColin Percival
3396ae1554aSColin PercivalThis won't work if you don't have write permissions to the directory
3406ae1554aSColin Percivaland probably won't be suitable if you're editing through a symbolic link.
3411909a1f4SAlfred Perlstein
3421909a1f4SAlfred PerlsteinIf you have sudo(8) installed and permissions to use it, type
3431909a1f4SAlfred Perlstein``<ESC>w ! sudo tee %'' to force a write.
3446ae1554aSColin Percival%
3456ae1554aSColin PercivalYou can adjust the volume of various parts of the sound system in your
3466ae1554aSColin Percivalcomputer by typing 'mixer <type> <volume>'.  To get a list of what you can
3476ae1554aSColin Percivaladjust, just type 'mixer'.
3486ae1554aSColin Percival%
3496ae1554aSColin PercivalYou can automatically download and install binary packages by doing
3506ae1554aSColin Percival
3516ae1554aSColin Percival	pkg install <package>
3526ae1554aSColin Percival
3536ae1554aSColin PercivalThis will also automatically install the packages that are dependencies
3546ae1554aSColin Percivalfor the package you install (ie, the packages it needs in order to work.)
3556ae1554aSColin Percival%
3566ae1554aSColin PercivalYou can change the video mode on all consoles by adding something like
3576ae1554aSColin Percivalthe following to /etc/rc.conf:
3586ae1554aSColin Percival
3596ae1554aSColin Percival	allscreens="80x30"
3606ae1554aSColin Percival
3616ae1554aSColin PercivalYou can use "vidcontrol -i mode | grep T" for a list of supported text
3626ae1554aSColin Percivalmodes.
3636ae1554aSColin Percival		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
3646ae1554aSColin Percival%
3656ae1554aSColin PercivalYou can disable tcsh's terminal beep if you `set nobeep'.
3666ae1554aSColin Percival%
3676ae1554aSColin PercivalYou can install extra packages for FreeBSD by using the ports system.
3686ae1554aSColin PercivalIf you have installed it, you can download, compile, and install software by
3696ae1554aSColin Percivaljust typing
3706ae1554aSColin Percival
3716ae1554aSColin Percival	# cd /usr/ports/<category>/<portname>
3726ae1554aSColin Percival	# make install && make clean
3736ae1554aSColin Percival
3746ae1554aSColin Percivalas root.  The ports infrastructure will download the software, change it so
3756ae1554aSColin Percivalit works on FreeBSD, compile it, install it, register the installation so it
3766ae1554aSColin Percivalwill be possible to automatically uninstall it, and clean out the temporary
3776ae1554aSColin Percivalworking space it used.  You can remove an installed port you decide you do not
3786ae1554aSColin Percivalwant after all by typing
3796ae1554aSColin Percival
3806ae1554aSColin Percival	# cd /usr/ports/<category>/<portname>
3816ae1554aSColin Percival	# make deinstall
3826ae1554aSColin Percival
3836ae1554aSColin Percivalas root.
3846ae1554aSColin Percival%
3856ae1554aSColin PercivalYou can look through a file in a nice text-based interface by typing
3866ae1554aSColin Percival
3876ae1554aSColin Percival	less filename
3886ae1554aSColin Percival%
3896ae1554aSColin PercivalYou can make a log of your terminal session with script(1).
3906ae1554aSColin Percival%
3916ae1554aSColin PercivalYou can often get answers to your questions about FreeBSD by searching in the
3926ae1554aSColin PercivalFreeBSD mailing list archives at
3936ae1554aSColin Percival
3941909a1f4SAlfred Perlstein	http://freebsd.markmail.org
3956ae1554aSColin Percival%
3966ae1554aSColin PercivalYou can open up a new split-screen window in (n)vi with :N or :E and then
3976ae1554aSColin Percivaluse ^w to switch between the two.
3986ae1554aSColin Percival%
3996ae1554aSColin PercivalYou can permanently set environment variables for your shell by putting them
4006ae1554aSColin Percivalin a startup file for the shell.  The name of the startup file varies
4016ae1554aSColin Percivaldepending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use
4026ae1554aSColin Percival.profile.  When using bash, sh, ksh or zsh, don't forget to export the
4036ae1554aSColin Percivalvariable.
4046ae1554aSColin Percival%
4056ae1554aSColin PercivalYou can press Ctrl-D to quickly exit from a shell, or logout from a
4066ae1554aSColin Percivallogin shell.
4076ae1554aSColin Percival		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
4086ae1554aSColin Percival%
4096ae1554aSColin PercivalYou can press up-arrow or down-arrow to walk through a list of
4106ae1554aSColin Percivalprevious commands in tcsh.
4116ae1554aSColin Percival%
4126ae1554aSColin PercivalYou can search for documentation on a keyword by typing
4136ae1554aSColin Percival
4146ae1554aSColin Percival	apropos keyword
4156ae1554aSColin Percival%
4166ae1554aSColin PercivalYou can `set autologout = 30' to have tcsh log you off automatically
4176ae1554aSColin Percivalif you leave the shell idle for more than 30 minutes.
4186ae1554aSColin Percival%
4196ae1554aSColin PercivalYou can use aliases to decrease the amount of typing you need to do to get
4206ae1554aSColin Percivalcommands you commonly use.  Examples of fairly popular aliases include (in
4216ae1554aSColin PercivalBourne shell style, as in /bin/sh, bash, ksh, and zsh):
4226ae1554aSColin Percival
4236ae1554aSColin Percival	alias lf="ls -FA"
4246ae1554aSColin Percival	alias ll="ls -lA"
4256ae1554aSColin Percival	alias su="su -m"
4266ae1554aSColin Percival
4276ae1554aSColin PercivalIn csh or tcsh, these would be
4286ae1554aSColin Percival
4296ae1554aSColin Percival	alias lf ls -FA
4306ae1554aSColin Percival	alias ll ls -lA
4316ae1554aSColin Percival	alias su su -m
4326ae1554aSColin Percival
4336ae1554aSColin PercivalTo remove an alias, you can usually use 'unalias aliasname'.  To list all
4346ae1554aSColin Percivalaliases, you can usually type just 'alias'.
4356ae1554aSColin Percival%
4366ae1554aSColin PercivalYou can use /etc/make.conf to control the options used to compile software
4376ae1554aSColin Percivalon this system.  Example entries are in
4381909a1f4SAlfred Perlstein/usr/share/examples/etc/make.conf and in make.conf(5).
4391909a1f4SAlfred PerlsteinFor options that are set for building FreeBSD's kernel and its world, see
4401909a1f4SAlfred Perlsteinsrc.conf(5).
4416ae1554aSColin Percival%
4426ae1554aSColin PercivalYou can use "pkg info" to see a list of packages you have installed.
4436ae1554aSColin Percival%
4446ae1554aSColin PercivalYou can use the 'fetch' command to retrieve files over ftp, http or https.
4456ae1554aSColin Percival
4467e3f9a34SEitan Adler	 fetch https://www.FreeBSD.org/index.html
4476ae1554aSColin Percival
4486ae1554aSColin Percivalwill download the front page of the FreeBSD web site.
4496ae1554aSColin Percival%
4506ae1554aSColin PercivalYou can use "whereis" to search standard binary, manual page and source
4516ae1554aSColin Percivaldirectories for the specified programs. This can be particularly handy
4526ae1554aSColin Percivalwhen you are trying to find where in the ports tree an application is.
4536ae1554aSColin Percival
4546ae1554aSColin PercivalTry "whereis firefox" and "whereis whereis".
4556ae1554aSColin Percival		-- Konstantinos Konstantinidis <kkonstan@duth.gr>
4566ae1554aSColin Percival%
4576ae1554aSColin PercivalWant to run the same command again?
458c92116f3SEitan AdlerIn many shells (e.g., tcsh, zsh, bash) you can type "!!".
4596ae1554aSColin Percival%
4606ae1554aSColin PercivalWant to go the directory you were just in?
4616ae1554aSColin PercivalType "cd -"
4626ae1554aSColin Percival%
4631909a1f4SAlfred PerlsteinCan't delete /usr/obj? Enter "chflags -R noschg /usr/obj" to remove the
4641909a1f4SAlfred Perlsteinsystem immutable flag for all files in /usr/obj.
4651909a1f4SAlfred Perlstein
4661909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4671909a1f4SAlfred Perlstein%
4681909a1f4SAlfred PerlsteinWant to list all files of an installed package? Enter
4691909a1f4SAlfred Perlstein"pkg info -l packagename".
4701909a1f4SAlfred Perlstein
4711909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4721909a1f4SAlfred Perlstein%
4731909a1f4SAlfred PerlsteinAre you looking for a package? Search for it with
4741909a1f4SAlfred Perlstein"pkg search part_of_package_name"
4751909a1f4SAlfred Perlstein
4761909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4771909a1f4SAlfred Perlstein%
4781909a1f4SAlfred PerlsteinIf you want to recursively copy a directory preserving file and directory
4791909a1f4SAlfred Perlsteinattributes use
4801909a1f4SAlfred Perlstein"cp -a source target"
4811909a1f4SAlfred Perlstein
4821909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4831909a1f4SAlfred Perlstein%
4841909a1f4SAlfred PerlsteinDo you wonder what a terminal program is doing at the moment? dd(1) does not
48573132e7bSAlfred Perlsteinshow any throughput? Hit "^T" (Control + t) to send SIGINFO to the process
4861909a1f4SAlfred Perlsteinand see what it is doing.
4871909a1f4SAlfred Perlstein
4881909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4891909a1f4SAlfred Perlstein%
4901909a1f4SAlfred PerlsteinDo you want to know which version of FreeBSD you are running? Enter
4911909a1f4SAlfred Perlstein"freebsd-version -ku" to display kernel and userland version.
4921909a1f4SAlfred Perlstein
4931909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4941909a1f4SAlfred Perlstein%
4951909a1f4SAlfred PerlsteinIf you want to end one or more processes at a time using a regular expression
4961909a1f4SAlfred Perlsteinenter "pkill regex".
4971909a1f4SAlfred Perlstein
4981909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
4991909a1f4SAlfred Perlstein%
5001909a1f4SAlfred PerlsteinDo you want to run a program directly after some other process has ended? Use
5011909a1f4SAlfred Perlstein"pwait pid && new_program"
5021909a1f4SAlfred Perlstein
5031909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5041909a1f4SAlfred Perlstein%
5051909a1f4SAlfred PerlsteinWhen you want your users to be able to reboot or shutdown FreeBSD, add them
5061909a1f4SAlfred Perlsteinto the group "operator" and they are allowed to use shutdown(8) and poweroff(8).
5071909a1f4SAlfred Perlstein
5081909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5091909a1f4SAlfred Perlstein%
5101909a1f4SAlfred PerlsteinIf you need to create a FAT32 formatted USB thumb drive, find out its devicename
5111909a1f4SAlfred Perlsteinrunning dmesg(8) after inserting it. Then create an MBR schema, a single slice and
5121909a1f4SAlfred Perlsteinformat it:
5131909a1f4SAlfred Perlstein
5141909a1f4SAlfred Perlstein# gpart create -s MBR ${devicename}
5151909a1f4SAlfred Perlstein# gpart add -t fat32 ${devicename}
5161909a1f4SAlfred Perlstein# newfs_msdos -F 32 -L thumbdrive ${devicename}s1
5171909a1f4SAlfred Perlstein
5181909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5191909a1f4SAlfred Perlstein%
5201909a1f4SAlfred PerlsteinIf you want to get a sorted list of all services that are started when FreeBSD boots,
5211909a1f4SAlfred Perlsteinenter "service -e".
5221909a1f4SAlfred Perlstein
5231909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5241909a1f4SAlfred Perlstein%
5251909a1f4SAlfred PerlsteinTo easily configure your installed FreeBSD use bsdconfig(8).
5261909a1f4SAlfred Perlstein
5271909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5281909a1f4SAlfred Perlstein%
5291909a1f4SAlfred PerlsteinAfter you compiled and installed a new version of FreeBSD, use etcupdate(8) to merge
5301909a1f4SAlfred Perlsteinconfiguration updates.
5311909a1f4SAlfred PerlsteinRun "etcupdate extract" once when your sources match your running system, then run
5321909a1f4SAlfred Perlstein"etcupdate" after every upgrade and "etcupdate resolve" to resolve any conflicts.
5331909a1f4SAlfred Perlstein
5341909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5351909a1f4SAlfred Perlstein%
5361909a1f4SAlfred PerlsteinDo you want to do a binary upgrade of your running FreeBSD installation? Use freebsd-update(8).
5371909a1f4SAlfred Perlstein
5381909a1f4SAlfred PerlsteinTo install updates and patches for the running branch use
5391909a1f4SAlfred Perlstein# freebsd-update fetch install
5401909a1f4SAlfred Perlstein
5411909a1f4SAlfred PerlsteinTo upgrade to a newer release use
5421909a1f4SAlfred Perlstein# freebsd-update upgrade -r ${name_of_release}
5431909a1f4SAlfred Perlstein
5441909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5451909a1f4SAlfred Perlstein%
5461909a1f4SAlfred PerlsteinTo run rc scripts in /etc/rc.d and /usr/local/etc/rc.d use service(8).
5471909a1f4SAlfred PerlsteinRun "service ${name_of_rc_script} start" to start a daemon and
5481909a1f4SAlfred Perlstein"service ${name_of_rc_script} stop" to stop it.
5491909a1f4SAlfred Perlstein
5501909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5511909a1f4SAlfred Perlstein%
5521909a1f4SAlfred PerlsteinIf you don't want to edit /etc/rc.conf directly, use sysrc(8) to add and remove entries.
5531909a1f4SAlfred PerlsteinUse "sysrc name=value" to add an entry and "sysrc -x name" to delete an entry.
5541909a1f4SAlfred Perlstein
5551909a1f4SAlfred Perlstein		-- Lars Engels <lme@FreeBSD.org>
5561909a1f4SAlfred Perlstein%
55756d417fdSBenedict ReuschlingYou can upload the dmesg of your system to help developers get an overview of commonly
55856d417fdSBenedict Reuschlingused hardware and peripherals for FreeBSD. Use the curl package to upload it like this:
559fd91f859SBenedict Reuschlingcurl -v -d "nickname=$USER" -d "description=FreeBSD/$(uname -m) on \
560fd91f859SBenedict Reuschling$(kenv smbios.system.maker) $(kenv smbios.system.product)" -d "do=addd" \
561fd91f859SBenedict Reuschling--data-urlencode 'dmesg@/var/run/dmesg.boot' http://dmesgd.nycbug.org/index.cgi
562fd91f859SBenedict Reuschling%
563*a9ea96eaSBenedict ReuschlingWant to know how much memory (in bytes) your machine has installed? Let
56456d417fdSBenedict Reuschlingsysctl(8) tell you with the following command:
56556d417fdSBenedict Reuschling
566*a9ea96eaSBenedict Reuschlingsysctl hw.realmem
567*a9ea96eaSBenedict Reuschling
568*a9ea96eaSBenedict ReuschlingThe realmem value is memory before the kernel and modules are loaded, whereas
569*a9ea96eaSBenedict Reuschlinghw.physmem is what is left after they were loaded.
57056d417fdSBenedict Reuschling
57156d417fdSBenedict ReuschlingThe number of active CPUs is displayed using this command:
57256d417fdSBenedict Reuschling
57356d417fdSBenedict Reuschlingsysctl hw.ncpu
57456d417fdSBenedict Reuschling
57556d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
57656d417fdSBenedict Reuschling%
577*a9ea96eaSBenedict ReuschlingWhen using ZFS as the file system the "df" command is reporting the pool size
578*a9ea96eaSBenedict Reuschlingand not file system sizes. It also does not know about descendent ZFS
579*a9ea96eaSBenedict Reuschlingdatasets, snapshots, quotas, and reservations with their individual space usage.
580*a9ea96eaSBenedict ReuschlingUse the built-in "zfs list" command to get a better overview of space usage:
58156d417fdSBenedict Reuschling
58256d417fdSBenedict Reuschlingzfs list -o space
58356d417fdSBenedict Reuschling
58456d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
58556d417fdSBenedict Reuschling%
58656d417fdSBenedict ReuschlingTo learn more about what your system is doing, take a look at systat(1). For
587*a9ea96eaSBenedict Reuschlingexample, to get various of statistics related to virtual memory usage, process
588*a9ea96eaSBenedict Reuschlingscheduling, device interrupts, system name translation caching, and disk I/O,
589*a9ea96eaSBenedict Reuschlingenter the following:
59056d417fdSBenedict Reuschling
591*a9ea96eaSBenedict Reuschlingsystat -vmstat
59256d417fdSBenedict Reuschling
593*a9ea96eaSBenedict ReuschlingOther values are icmp, icmp6, ifstat, iostat, ip, ip6, netstat, pigs, sctp,
594*a9ea96eaSBenedict Reuschlingswap, tcp, or zarc. You can switch between displays using :<display> and exit
59556d417fdSBenedict Reuschlingback to your shell by typing
59656d417fdSBenedict Reuschling
59756d417fdSBenedict Reuschling:quit
59856d417fdSBenedict Reuschling
59956d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
60056d417fdSBenedict Reuschling%
60156d417fdSBenedict ReuschlingTo set a quota of 10 GB for the user named foo on a ZFS dataset, run the
60256d417fdSBenedict Reuschlingfollowing command:
60356d417fdSBenedict Reuschling
60456d417fdSBenedict Reuschling# zfs set userquota@foo=10G pool/home/foo
60556d417fdSBenedict Reuschling
60656d417fdSBenedict ReuschlingThe zfs userspace command can display the quota and current space usage:
60756d417fdSBenedict Reuschling
60856d417fdSBenedict Reuschling# zfs userspace pool/home/foo
60956d417fdSBenedict Reuschling
61056d417fdSBenedict ReuschlingTo unset a quota, assign "none" as the value.
61156d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
61256d417fdSBenedict Reuschling%
61356d417fdSBenedict ReuschlingZFS can display I/O statistics for a given pool using the iostat subcommand.
61456d417fdSBenedict ReuschlingBy default, it will display one line of current activity.  To display stats
61556d417fdSBenedict Reuschlingevery 5 seconds run the following command (cancel with CTRL+C):
61656d417fdSBenedict Reuschling
61756d417fdSBenedict Reuschlingzpool iostat 5
61856d417fdSBenedict Reuschling
61956d417fdSBenedict ReuschlingTo view individual disk activities, specify the -v parameter:
62056d417fdSBenedict Reuschling
62156d417fdSBenedict Reuschlingzpool iostat -v
62256d417fdSBenedict Reuschling
62356d417fdSBenedict ReuschlingOf course, both can be combined. For more options, see zpool(8).
62456d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
62556d417fdSBenedict Reuschling%
62656d417fdSBenedict ReuschlingFreeBSD's top(1) utility displays CPU statistics by default.
62756d417fdSBenedict ReuschlingTo display I/O activity for each process instead, run top like this:
62856d417fdSBenedict Reuschling
62956d417fdSBenedict Reuschlingtop -m io
63056d417fdSBenedict Reuschling
63156d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
63256d417fdSBenedict Reuschling%
63356d417fdSBenedict ReuschlingZFS keeps a history of commands run against a specific pool using the
63456d417fdSBenedict Reuschlinghistory subcommand to zpool:
63556d417fdSBenedict Reuschling
63656d417fdSBenedict Reuschlingzpool history
63756d417fdSBenedict Reuschling
63856d417fdSBenedict ReuschlingMore details are available using the -i and -l parameters. Note that ZFS
63956d417fdSBenedict Reuschlingwill not keep the complete pool history forever and will remove older
64056d417fdSBenedict Reuschlingevents in favor of never ones.
64156d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
64256d417fdSBenedict Reuschling%
64356d417fdSBenedict ReuschlingTo display the compression ratio for the ZFS dataset /var/log on the pool
64456d417fdSBenedict Reuschlingmypool, run the following command:
64556d417fdSBenedict Reuschling
64656d417fdSBenedict Reuschlingzfs get refcompressratio mypool/var/log
64756d417fdSBenedict Reuschling
64856d417fdSBenedict ReuschlingThe refcompressratio will only display the compression ratio for that specific
64956d417fdSBenedict Reuschlingdataset, not the descendant datasets. To include the child datasets, the
65056d417fdSBenedict Reuschlingcommand looks like this:
65156d417fdSBenedict Reuschling
65256d417fdSBenedict Reuschlingzfs get compressratio mypool/var
65356d417fdSBenedict Reuschling
65456d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
65556d417fdSBenedict Reuschling%
65656d417fdSBenedict ReuschlingYou can limit the depth of the displayed datasets in the "zfs list" output
65756d417fdSBenedict Reuschlingusing the -d parameter. To display only the first level of datasets below
65856d417fdSBenedict Reuschlingmypool/usr and not the ones deeper than those, run this command:
65956d417fdSBenedict Reuschling
66056d417fdSBenedict Reuschlingzfs list -d 1 mypool/usr
66156d417fdSBenedict Reuschling
66256d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
66356d417fdSBenedict Reuschling%
66456d417fdSBenedict ReuschlingThe "zfs list" command can be filtered in multiple ways. To display just
66556d417fdSBenedict Reuschlingthe dataset name, use the -o parameter:
66656d417fdSBenedict Reuschling
66756d417fdSBenedict Reuschlingzfs list -o name mypool/usr
66856d417fdSBenedict Reuschling
66956d417fdSBenedict ReuschlingMore columns and their order can be defined by separating them with commas:
67056d417fdSBenedict Reuschling
67156d417fdSBenedict Reuschlingzfs list -o mountpoint,name,avail
67256d417fdSBenedict Reuschling
67356d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
67456d417fdSBenedict Reuschling%
67556d417fdSBenedict ReuschlingThe output of "zfs list" can be sorted by a specific column using -s.  To
67656d417fdSBenedict Reuschlingsort the datasets by the "used" column in ascending order, run this command:
67756d417fdSBenedict Reuschling
67856d417fdSBenedict Reuschlingzfs list -s used
67956d417fdSBenedict Reuschling
68056d417fdSBenedict ReuschlingTo sort in descending order instead, use -S:
68156d417fdSBenedict Reuschling
68256d417fdSBenedict Reuschlingzfs list -S used
68356d417fdSBenedict Reuschling
68456d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
68556d417fdSBenedict Reuschling%
68656d417fdSBenedict ReuschlingTo make the "zfs list" output more script-friendly, you can suppress the
68756d417fdSBenedict Reuschlingoutput of the headers for each column by passing the -H parameter:
68856d417fdSBenedict Reuschling
68956d417fdSBenedict Reuschlingzfs list -H
69056d417fdSBenedict Reuschling
69156d417fdSBenedict ReuschlingAnother helpful option for script writers is -p, which displays the numbers
69256d417fdSBenedict Reuschlingin non-rounded, exact values:
69356d417fdSBenedict Reuschling
69456d417fdSBenedict Reuschlingzfs list -p
69556d417fdSBenedict Reuschling
69656d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
69756d417fdSBenedict Reuschling%
69856d417fdSBenedict ReuschlingBefore deleting a dataset or snapshot, perform a dry run using the -n
69956d417fdSBenedict Reuschlingparameter. This is to make sure you really want to delete just that
70056d417fdSBenedict Reuschlingdataset/snapshot and not any dependent ones. ZFS will display the resulting
70156d417fdSBenedict Reuschlingaction when -n is combined with the -v option without actually performing
70256d417fdSBenedict Reuschlingit:
70356d417fdSBenedict Reuschling
704*a9ea96eaSBenedict Reuschlingzfs destroy -nrv mypool@mysnap
70556d417fdSBenedict Reuschling
70656d417fdSBenedict ReuschlingOnce you are sure this is exactly what you intend to do, remove the -n
70756d417fdSBenedict Reuschlingparameter to execute the destroy operation.
70856d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
70956d417fdSBenedict Reuschling%
71056d417fdSBenedict ReuschlingYou can delete a range of ZFS snapshots (a-z) in multiple ways.
71156d417fdSBenedict ReuschlingThe following will delete d and all earlier snapshots:
71256d417fdSBenedict Reuschling
71356d417fdSBenedict Reuschlingzfs destroy mypool/data@%d
71456d417fdSBenedict Reuschling
71556d417fdSBenedict ReuschlingTo delete d and all later snapshots:
71656d417fdSBenedict Reuschling
71756d417fdSBenedict Reuschlingzfs destroy mypool/data@d%
71856d417fdSBenedict Reuschling
71956d417fdSBenedict ReuschlingTo delete all dataset snapshots:
72056d417fdSBenedict Reuschling
72156d417fdSBenedict Reuschlingzfs destroy mypool/data@%
72256d417fdSBenedict Reuschling
72356d417fdSBenedict ReuschlingMake sure to let ZFS perform a dry run (-n option) first and display (-v) what
72456d417fdSBenedict Reuschlingit would do to confirm that the delete operation is removing exactly what you
72556d417fdSBenedict Reuschlingintended.
72656d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
72756d417fdSBenedict Reuschling%
72856d417fdSBenedict ReuschlingTo set a custom ZFS property on the mypool pool, you need to provide it
72956d417fdSBenedict Reuschlingusing the "key1:key2=value" syntax, where the colon (:) is used as the
73056d417fdSBenedict Reuschlingseparator and identifier from the built-in ZFS properties:
73156d417fdSBenedict Reuschling
73256d417fdSBenedict Reuschling# zfs set warranty:expires=2038-01-19 mypool
73356d417fdSBenedict Reuschling
73456d417fdSBenedict ReuschlingThe custom property is applied to all datasets and can be queried like any
73556d417fdSBenedict Reuschlingbuilt-in properties using zfs get:
73656d417fdSBenedict Reuschling
73756d417fdSBenedict Reuschlingzfs get warranty:expires mypool
73856d417fdSBenedict Reuschling
73956d417fdSBenedict ReuschlingTo reset the value of a custom property, use the inherit subcommand:
74056d417fdSBenedict Reuschling
74156d417fdSBenedict Reuschling# zfs inherit warranty:expires mypool
74256d417fdSBenedict Reuschling
74356d417fdSBenedict ReuschlingRemoving a custom property from a pool is done using the -r flag to the
74456d417fdSBenedict Reuschling"zfs inherit" command:
74556d417fdSBenedict Reuschling
74656d417fdSBenedict Reuschling# zfs inherit -r warranty:expires mypool
74756d417fdSBenedict Reuschling
74856d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
74956d417fdSBenedict Reuschling%
75056d417fdSBenedict ReuschlingTo delete a range of ZFS snapshots, use the % (percent) character after the
75156d417fdSBenedict Reuschlingfull path to the first snapshot that should be included. For example, to
75256d417fdSBenedict Reuschlingsimulate deleting snapshots a through (including) d, use this command:
75356d417fdSBenedict Reuschling
75456d417fdSBenedict Reuschling# zfs destroy -rvn mypool/tmp@a%d
75556d417fdSBenedict Reuschling
75656d417fdSBenedict ReuschlingOnce you are sure that this is what you want, remove the -n option:
75756d417fdSBenedict Reuschling
75856d417fdSBenedict Reuschling# zfs destroy -rv mypool/tmp@a%d
75956d417fdSBenedict Reuschling
76056d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
76156d417fdSBenedict Reuschling%
76256d417fdSBenedict ReuschlingYou can prevent the removal of a ZFS snapshot by using the hold subcommand.
76356d417fdSBenedict ReuschlingFor example, to prevent the snapshot called milestone from deletion, run the
76456d417fdSBenedict Reuschlingfollowing command:
76556d417fdSBenedict Reuschling
76656d417fdSBenedict Reuschling# zfs hold milestone_hold mypool/projects@my_milestone
76756d417fdSBenedict Reuschling
76856d417fdSBenedict ReuschlingThe "zfs holds" command will list all current snapshots that are protected
76956d417fdSBenedict Reuschlingthis way (-r for a recursive list):
77056d417fdSBenedict Reuschling
77156d417fdSBenedict Reuschling# zfs holds -r mypool
77256d417fdSBenedict Reuschling
77356d417fdSBenedict ReuschlingThe TIMESTAMP column in the output of the above command is from when the
77456d417fdSBenedict Reuschlinghold was created, not the snapshot it holds. The "zfs destroy" command will
77556d417fdSBenedict Reuschlingecho a "dataset is busy" message on the console when it encounters a hold.
77656d417fdSBenedict ReuschlingUse "zfs release" to release the hold on the snapshot:
77756d417fdSBenedict Reuschling
77856d417fdSBenedict Reuschling# zfs release milestone_hold mypool/projects@my_milestone
77956d417fdSBenedict Reuschling
78056d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
78156d417fdSBenedict Reuschling%
78256d417fdSBenedict ReuschlingA user "sender" needs the following permissions set to send a ZFS dataset:
78356d417fdSBenedict Reuschling
78456d417fdSBenedict Reuschling# zfs allow -u sender send,snapshot txpool
78556d417fdSBenedict Reuschling
78656d417fdSBenedict ReuschlingOn the receiving side, the user "receiver" requires these permissions:
78756d417fdSBenedict Reuschling
78856d417fdSBenedict Reuschling# zfs allow -u receiver compression,mountpoint,mount,create,receive rxpool
78956d417fdSBenedict Reuschling
79056d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
79156d417fdSBenedict Reuschling%
79256d417fdSBenedict ReuschlingDon't let your zpool fill up completely by creating a dataset with
79356d417fdSBenedict Reuschlingreservation.
79456d417fdSBenedict Reuschling
79556d417fdSBenedict Reuschling# zfs create -o refreservation=<5% of total pool space> <poolname>/reserved
79656d417fdSBenedict Reuschling
79756d417fdSBenedict ReuschlingYou can always shrink the reserve if you need the space, but your pool will
79856d417fdSBenedict Reuschlingalways have space left this way.
79956d417fdSBenedict Reuschling
80056d417fdSBenedict Reuschling		-- Benedict Reuschling <bcr@FreeBSD.org>
80156d417fdSBenedict Reuschling%
802