freebsd-tips revision 106986
1107002SschweikhThis fortune brought to you by: 2174422Sdougb$FreeBSD: head/games/fortune/datfiles/freebsd-tips 106986 2002-11-16 13:24:44Z joerg $ 32490Sjkh% 42490SjkhHaving trouble using fetch through a firewall? Try setting the environment 52490Sjkhvariable FTP_PASSIVE_MODE to yes, and see fetch(3) for more details. 62490Sjkh% 72490SjkhBy pressing "Scroll Lock" you can use the arrow keys to scroll backward 82490Sjkhthrough the console output. Press "Scroll Lock" again to turn it off. 92490Sjkh% 102490SjkhWant colour in your directory listings? Use "ls -G". "ls -F" is also useful, 112490Sjkhand they can be combined as "ls -FG". 122490Sjkh% 132490SjkhIf you need to ask a question on the FreeBSD-questions mailing list then 142490Sjkh 152490Sjkh http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\ 162490Sjkh freebsd-questions/index.html 172490Sjkh 182490Sjkhcontains lots of useful advice to help you get the best results. 192490Sjkh% 202490SjkhIf you'd like to keep track of applications in the FreeBSD ports tree, take a 212490Sjkhlook at FreshPorts; 222490Sjkh 232490Sjkh http://www.freshports.org/ 242490Sjkh% 252490SjkhTo search for files that match a particular name, use find(1); for example 262490Sjkh 272490Sjkh find / -name "*GENERIC*" -ls 282490Sjkh 292490Sjkhwill search '/', and all subdirectories, for files with 'GENERIC' in the name. 302490Sjkh -- Stephen Hilton <nospam@hiltonbsd.com> 312490Sjkh% 322490SjkhIn tcsh, you can `set autolist' to have the shell automatically show 332490Sjkhall the possible matches when doing filename/directory expansion. 342490Sjkh% 352490SjkhYou can `set autologout = 30' to have tcsh log you off automatically 362490Sjkhif you leave the shell idle for more than 30 minutes. 372490Sjkh% 382490SjkhIf you `set filec' (file completion) in tcsh and write a part of the 392490Sjkhfilename, pressing TAB will show you the available choices when there 402490Sjkhis more than one, or complete the filename if there's only one match. 412490Sjkh% 422490SjkhYou can press up-arrow or down-arrow to walk through a list of 432490Sjkhprevious commands in tcsh. 442490Sjkh% 452490SjkhYou can disable tcsh's terminal beep if you `set nobeep'. 462490Sjkh% 472490SjkhIf you `set watch = (0 any any)' in tcsh, you will be notified when 482490Sjkhsomeone logs in or out of your system. 492490Sjkh% 502490SjkhNice tcsh prompt: set prompt = '%m %# ' 512490Sjkh% 522490SjkhNice tcsh prompt: set prompt = '%n@%m%# ' 532490Sjkh% 54174422SdougbNice tcsh prompt: set prompt = '%n@%m:%~%# ' 55174422Sdougb% 562490SjkhNice tcsh prompt: set prompt = '%n@%m:%/%# ' 572490Sjkh% 582490SjkhNice tcsh prompt: set prompt = '[%B%m%b] %B%~%b%# ' 592490Sjkh% 602490SjkhSimple tcsh prompt: set prompt = '%# ' 612490Sjkh% 622490SjkhIf you want df(1) and other commands to display disk sizes in 632490Sjkhkilobytes instead of 512-byte blocks, set BLOCKSIZE in your 642490Sjkhenvironment to 'K'. You can also use 'M' for Megabytes or 'G' for 652490SjkhGigabytes. If you want df(1) to automatically select the best size 662490Sjkhthen use 'df -h'. 672490Sjkh% 682490SjkhTo change an environment variable in tcsh you use: setenv NAME "value" 692490Sjkhwhere NAME is the name of the variable and "value" its new value. 70174422Sdougb% 71174422SdougbTo change an environment variable in /bin/sh use: 72174422Sdougb 73174422Sdougb $ VARIABLE="value" 74174422Sdougb $ export VARIABLE 75174422Sdougb% 762490SjkhYou can use /etc/make.conf to control the options used to compile software 772490Sjkhon this system. Example entries are in 782490Sjkh/usr/share/examples/etc/defaults/make.conf. 792490Sjkh% 80162709SschweikhTo do a fast search for a file, try 812490Sjkh 822490Sjkh locate filename 832490Sjkh 842490Sjkhlocate uses a database that is updated every Saturday (assuming your computer 852490Sjkhis running FreeBSD at the time) to quickly find files based on name only. 862490Sjkh% 872490SjkhIn order to search for a string in some files, use 'grep' like this: 882490Sjkh 892490Sjkh grep "string" filename1 [filename2 filename3 ...] 902490Sjkh 912490SjkhThis will print out the lines in the files that contain the string. grep can 922490Sjkhalso do a lot more advanced searches - type 'man grep' for details. 932490Sjkh% 942490SjkhYou can use the 'fetch' command to retrieve files over ftp or http. 952490Sjkh 962490Sjkh fetch http://www.freebsd.org/index.html 972490Sjkh 982490Sjkhwill download the front page of the FreeBSD web site. 992490Sjkh% 1002490SjkhIn order to make fetch (the FreeBSD downloading tool) ask for 1012490Sjkhusername/password when it encounter a password-protected web page, you can set 1022490Sjkhthe environment variable HTTP_AUTH to 'basic:*'. 1032490Sjkh% 1042490SjkhYou can permanently set environment variables for your shell by putting them 1052490Sjkhin a startup file for the shell. The name of the startup file varies 1062490Sjkhdepending on the shell - csh and tcsh uses .login, bash, sh, ksh and zsh use 1072490Sjkh.profile. When using bash, sh, ksh or zsh, don't forget to export the 1082490Sjkhvariable. 1092490Sjkh% 1102490SjkhIf you are running xterm, the default TERM variable will be 'xterm'. If you 1112490Sjkhset this environment variable to 'xterm-color' instead, a lot of programs will 1122490Sjkhuse colors. You can do this by 1132490Sjkh 1142490Sjkh TERM=xterm-color; export TERM 1152490Sjkh 1162490Sjkhin Bourne-derived shells, and 1172490Sjkh 1182490Sjkh setenv TERM xterm-color 1192490Sjkh 1202490Sjkhin csh-derived shells. 1212490Sjkh% 1222490SjkhIf you do not want to get beeps in X11 (X Windows), you can turn them off with 1232490Sjkh 1242490Sjkh xset b off 1252490Sjkh% 1262490SjkhYou can look through a file in a nice text-based interface by typing 1272490Sjkh 1282490Sjkh less filename 1292490Sjkh% 1302490SjkhThe default editor in FreeBSD is vi, which is efficient to use when you have 1312490Sjkhlearned it, but somewhat user-unfriendly. To use ee (an easier but less 1322490Sjkhpowerful editor) instead, set the environment variable EDITOR to /usr/bin/ee 1332490Sjkh% 1342490SjkhIf you accidently end up inside vi, you can quit it by pressing Escape, colon 135174422Sdougb(:), q (q), bang (!) and pressing return. 136174422Sdougb% 1372490SjkhYou can use aliases to decrease the amount of typing you need to do to get 1382490Sjkhcommands you commonly use. Examples of fairly popular aliases include (in 1392490Sjkhbourne shell style, as in /bin/sh, bash, ksh, and zsh): 1402490Sjkh 1412490Sjkh alias lf="ls -FA" 1422490Sjkh alias ll="ls -lA" 1432490Sjkh alias su="su -m" 1442490Sjkh 1452490SjkhIn csh or tcsh, these would be 1462490Sjkh 1472490Sjkh alias lf ls -FA 1482490Sjkh alias ll ls -lA 1492490Sjkh alias su su -m 1502490Sjkh 1512490SjkhTo remove an alias, you can usually use 'unalias aliasname'. To list all 1522490Sjkhaliases, you can usually type just 'alias'. 1532490Sjkh% 1542490SjkhIn order to support national characters for european languages in tools like 155174422Sdougbless without creating other nationalisation aspects, set the environment 156174422Sdougbvariable LC_ALL to 'en_US.ISO8859-1'. 1572490Sjkh% 1582490SjkhYou can search for documentation on a keyword by typing 1592490Sjkh 1602490Sjkh apropos keyword 1612490Sjkh% 1622490SjkhMan pages are divided into section depending on topic. There are 9 different 163174422Sdougbsections numbered from 1 (General Commands) to 9 (Kernel Developer's Manual). 164174422SdougbYou can get an introduction to each topic by typing 1652490Sjkh 1662490Sjkh man <number> intro 1672490Sjkh 1682490SjkhIn other words, to get the intro to general commands, type 1692490Sjkh 1702490Sjkh man 1 intro 1712490Sjkh% 1722490SjkhFreeBSD is started up by the program 'init'. The first thing init does when 1732490Sjkhstarting multiuser mode (ie, starting the computer up for normal use) is to 1742490Sjkhrun the shell script /etc/rc. By reading /etc/rc, you can learn a lot about 1752490Sjkhhow the system is put together, which again will make you more confident about 1762490Sjkhwhat happens when you do something with it. 1772490Sjkh% 1782490SjkhIf you want to play CDs with FreeBSD, a utility for this is already included. 1792490SjkhType 'cdcontrol' then 'help' to learn more. (You may need to set the CDROM 1802490Sjkhenvironment variable in order to make cdcontrol want to start.) 1812490Sjkh% 1822490SjkhIf you have a CD-ROM drive in your machine, you can make the CD-ROM that is 1832490Sjkhpresently inserted available by typing 'mount /cdrom' as root. The CD-ROM 1842490Sjkhwill be available under /cdrom/. Remember to do 'umount /cdrom' before 1852490Sjkhremoving the CD-ROM (it will usually not be possible to remove the CD-ROM 1862490Sjkhwithout doing this.) 1872490Sjkh 1882490SjkhNote: This tip may not work in all configurations. 1892490Sjkh% 1902490SjkhYou can install extra packages for FreeBSD by using the ports system. 1912490SjkhIf you have installed it, you can download, compile, and install software by 1922490Sjkhjust typing 1932490Sjkh 1942490Sjkh # cd /usr/ports/<category>/<portname> 195174422Sdougb # make install && make clean 196174422Sdougb 197174422Sdougbas root. The ports infrastructure will download the software, change it so 1982490Sjkhit works on FreeBSD, compile it, install it, register the installation so it 1992490Sjkhwill be possible to automatically uninstall it, and clean out the temporary 2002490Sjkhworking space it used. You can remove an installed port you decide you do not 2012490Sjkhwant after all by typing 2022490Sjkh 2032490Sjkh # cd /usr/ports/<category>/<portname> 2042490Sjkh # make deinstall 2052490Sjkh 2062490Sjkhas root. 2072490Sjkh% 2082490SjkhNice bash prompt: PS1='(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$ ' 2092490Sjkh -- Mathieu <mathieu@hal.interactionvirtuelle.com> 2102490Sjkh% 2112490SjkhTo see the output from when your computer started, run dmesg(8). If it has 2122490Sjkhbeen replaced with other messages, look at /var/run/dmesg.boot. 2132490Sjkh -- Francisco Reyes <lists@natserv.com> 2142490Sjkh% 2152490SjkhYou can use "whereis" to locate standard binary, manual page and source 2162490Sjkhdirectories for the specified programs. This can be particularly handy 2172490Sjkhwhen you are trying to find where in the ports tree an application is. 2182490Sjkh 2192490SjkhTry "whereis netscape" and "whereis whereis". 2202490Sjkh -- Konstantinos Konstantinidis <kkonstan@duth.gr> 2212490Sjkh% 2222490SjkhYou can press Ctrl-D to quickly exit from a shell, or logout from a 2232490Sjkhlogin shell. 2242490Sjkh -- Konstantinos Konstantinidis <kkonstan@duth.gr> 2252490Sjkh% 2262490SjkhYou can use "pkg_info" to see a list of packages you have installed. 2272490Sjkh -- Konstantinos Konstantinidis <kkonstan@duth.gr> 2282490Sjkh% 2292490SjkhYou can change the video mode on all consoles by adding something like 2302490Sjkhthe following to /etc/rc.conf: 2312490Sjkh 2322490Sjkh allscreens="80x30" 2332490Sjkh 2342490SjkhYou can use "vidcontrol -i mode | grep T" for a list of supported text 2352490Sjkhmodes. 2362490Sjkh -- Konstantinos Konstantinidis <kkonstan@duth.gr> 2372490Sjkh% 2382490SjkhAny user that is a member of the wheel group can use "su -" to simulate 2392490Sjkha root login. You can add a user to the wheel group by editing /etc/group. 2402490Sjkh -- Konstantinos Konstantinidis <kkonstan@duth.gr> 2412490Sjkh% 2422490SjkhOver quota? "du -s * | sort -n " will give you a sorted list of your 2432490Sjkhdirectory sizes. 2442490Sjkh -- David Scheidt <dscheidt@tumbolia.com> 2452490Sjkh% 2462490SjkhHandy bash(1) prompt: PS1="\u@\h \w \!$ " 2472490Sjkh -- David Scheidt <dscheidt@tumbolia.com> 2482490Sjkh% 2492490SjkhEver wonder what those numbers after command names were, as in cat(1)? It's 2502490Sjkhthe section of the manual the man page is in. "man man" will tell you more. 2512490Sjkh -- David Scheidt <dscheidt@tumbolia.com> 2522490Sjkh% 2532490Sjkh"man hier" will explain the way FreeBSD filesystems are normally laid out. 2542490Sjkh -- David Scheidt <dscheidt@tumbolia.com> 2552490Sjkh% 2562490Sjkh"man tuning" gives some tips how to tune performance of your FreeBSD system. 2572490Sjkh -- David Scheidt <dscheidt@tumbolia.com> 2582490Sjkh% 2592490Sjkh"man firewall" will give advice for building a FreeBSD firewall 2602490Sjkh -- David Scheidt <dscheidt@tumbolia.com> 2612490Sjkh% 2622490SjkhYou can often get answers to your questions about FreeBSD by searching in the 2632490SjkhFreeBSD mailing list archives at 2642490Sjkh 2652490Sjkh http://www.freebsd.org/search.html 2662490Sjkh% 2672490SjkhYou can adjust the volume of various parts of the sound system in your 2682490Sjkhcomputer by typing 'mixer <type> <volume>'. To get a list of what you can 2692490Sjkhadjust, just type 'mixer'. 2702490Sjkh% 2712490SjkhYou can automatically download and install binary packages by doing 272149634Sschweikh 273149634Sschweikh pkg_add -r <URL> 2742490Sjkh 2752490Sjkhwhere you replace <URL> with the URL to the package. This will also 2762490Sjkhautomatically install the packages the package you download is dependent on 2772490Sjkh(ie, the packages it needs in order to work.) 2782490Sjkh% 2792490SjkhYou can get a good standard workstation install by using the 2802490Sjkhinstant-workstation port/package. If you have ports installed, you can 281174422Sdougbinstall it by doing 282174422Sdougb 283174422Sdougb # cd /usr/ports/misc/instant-workstation 284174422Sdougb # make install && make clean 2852490Sjkh 2862490Sjkhas root. This will install a collection of packages that is convenient to 2872490Sjkhhave on a workstation. 2882490Sjkh% 2892490SjkhYou can get a good generic server install by using the 2902490Sjkhinstant-server port/package. If you have ports installed, you can 2912490Sjkhinstall it by doing 2922490Sjkh 2932490Sjkh # cd /usr/ports/misc/instant-server 2942490Sjkh # make install && make clean 2952490Sjkh 2962490Sjkhas root. This will install a collection of packages that is appropriate for 2972490Sjkhrunning a "generic" server. 2982490Sjkh% 2992490SjkhYou can make a log of your terminal session with script(1). 3002490Sjkh% 3012490Sjkh"man ports" gives many useful hints about installing FreeBSD ports. 302174422Sdougb% 303174422Sdougb"man security" gives very good advice on how to tune the security of your 3042490SjkhFreeBSD system. 3052490Sjkh% 3062490SjkhWant to find a specific port, just type the following under /usr/ports, 3072490Sjkhor one its subdirectories: 3082490Sjkh 309174422Sdougb "make search port=<port-name>" 310174422Sdougb or 311174422Sdougb "make search key="<keyword>" 3122490Sjkh% 3132490SjkhWant to see how much virtual memory you're using? Just type "swapinfo" to 3142490Sjkhbe shown information about the usage of your swap partitions. 3152490Sjkh% 3162490Sjkhports/net/netcat port is useful not only for redirecting input/output 3172490Sjkhto TCP or UDP connections, but also for proxying them. See inetd(8) for 3182490Sjkhdetails. 3192490Sjkh% 3202490SjkhIf other operating systems have damaged your Master Boot Record, you can 3212490Sjkhreinstall it either with /stand/sysinstall or with boot0cfg(8). See 3222490Sjkh"man boot0cfg" for details. 3232490Sjkh% 3242490SjkhNeed to see the calendar for this month? Simply type "cal". To see the 325174422Sdougbwhole year, type "cal -y". 3262490Sjkh -- Dru <genesis@istar.ca> 3272490Sjkh% 3282490SjkhNeed to quickly return to your home directory? Type "cd". 3292490Sjkh -- Dru <genesis@istar.ca> 3302490Sjkh% 3312490SjkhTo see the last time that you logged in, use lastlogin(8). 3322490Sjkh -- Dru <genesis@istar.ca> 3332490Sjkh% 3342490SjkhTo clear the screen, use "clear". To re-display your screen buffer, press 3352490Sjkhthe scroll lock key and use your page up button. When you're finished, 3362490Sjkhpress the scroll lock key again to get your prompt back. 3372490Sjkh -- Dru <genesis@istar.ca> 3382490Sjkh% 3392490SjkhTo save disk space in your home directory, compress files you rarely 3402490Sjkhuse with "gzip filename". 3412490Sjkh -- Dru <genesis@istar.ca> 3422490Sjkh% 3432490SjkhTo read a compressed file without having to first uncompress it, use 3442490Sjkh"zcat" or "zmore" to view it. 3452490Sjkh -- Dru <genesis@istar.ca> 3462490Sjkh% 3472490SjkhTo see how much disk space is left on your partitions, use 3482490Sjkh 3492490Sjkh df -h 3502490Sjkh -- Dru <genesis@istar.ca> 3512490Sjkh% 3522490SjkhTo see the 10 largest files on a directory or partition, use 3532490Sjkh 354174422Sdougb du /partition_or_directory_name | sort -rn | head 355174422Sdougb -- Dru <genesis@istar.ca> 3562490Sjkh% 3572490SjkhTo determine whether a file is a text file, executable, or some other type 3582490Sjkhof file, use 3592490Sjkh 3602490Sjkh file filename 3612490Sjkh -- Dru <genesis@istar.ca> 3622490Sjkh% 3632490SjkhTime to change your password? Type "passwd" and follow the prompts. 3642490Sjkh -- Dru <genesis@istar.ca> 3652490Sjkh% 3662490SjkhWant to know how many words, lines, or bytes are contained in a file? Type 3672490Sjkh"wc filename". 3682490Sjkh -- Dru <genesis@istar.ca> 3692490Sjkh% 3702490SjkhNeed to print a manpage? Use 3712490Sjkh 3722490Sjkh man name_of_manpage | col -bx | lpr 3732490Sjkh -- Dru <genesis@istar.ca> 3742490Sjkh% 3752490SjkhNeed to remove all those ^M characters from a DOS file? Try 3762490Sjkh 3772490Sjkh col -bx < dosfile > newfile 3782490Sjkh -- Dru <genesis@istar.ca> 3792490Sjkh% 3802490SjkhForget what directory you are in? Type "pwd". 3812490Sjkh -- Dru <genesis@istar.ca> 3822490Sjkh% 3832490SjkhIf you are in the C shell and have just installed a new program, you won't 3842490Sjkhbe able to run it unless you first type "rehash". 3852490Sjkh -- Dru <genesis@istar.ca> 3862490Sjkh% 3872490SjkhNeed to leave your terminal for a few minutes and don't want to logout? 3882490SjkhUse "lock -p". When you return, use your password as the key to unlock the 389108666Sschweikhterminal. 3902490Sjkh -- Dru <genesis@istar.ca> 3912490Sjkh% 3922490SjkhNeed to find the location of a program? Use "locate program_name". 3932490Sjkh -- Dru <genesis@istar.ca> 3942490Sjkh% 3952490SjkhForget how to spell a word or a variation of a word? Use 3962490Sjkh 3972490Sjkh look portion_of_word_you_know 3982490Sjkh -- Dru <genesis@istar.ca> 3992490Sjkh% 4002490SjkhTo see the last 10 lines of a long file, use "tail filename". To see the 4012490Sjkhfirst 10 lines, use "head filename". 4022490Sjkh -- Dru <genesis@istar.ca> 4032490Sjkh% 4042490SjkhTo see how long it takes a command to run, type the word "time" before the 4052490Sjkhcommand name. 4062490Sjkh -- Dru <genesis@istar.ca> 4072490Sjkh% 4082490SjkhTo quickly create an empty file, use "touch filename". 4092490Sjkh -- Dru <genesis@istar.ca> 4102490Sjkh% 4112490SjkhTo find out the hostname associated with an IP address, use 4122490Sjkh 4132490Sjkh dig -x IP_address 4142490Sjkh -- Dru <genesis@istar.ca> 4152490Sjkh% 4162490SjkhIf you use the C shell, add the following line to the .cshrc file in your 4172490Sjkhhome directory to prevent core files from being written to disk: 4182490Sjkh 4192490Sjkh limit coredumpsize 0 4202490Sjkh -- Dru <genesis@istar.ca> 4212490Sjkh% 4222490SjkhIf you need a reminder to leave your terminal, type "leave +hhmm" where 4232490Sjkh"hhmm" represents in how many hours and minutes you need to leave. 4242490Sjkh -- Dru <genesis@istar.ca> 4252490Sjkh% 4262490SjkhNeed to do a search in a manpage or in a file you've sent to a pager? Use 4272490Sjkh"/search_word". To repeat the same search, type "n" for next. 4282490Sjkh -- Dru <genesis@istar.ca> 4292490Sjkh% 4302490SjkhForget when Easter is? Try "ncal -e". If you need the date for Orthodox 4312490SjkhEaster, use "ncal -o" instead. 4322490Sjkh -- Dru <genesis@istar.ca> 4332490Sjkh% 4342490SjkhNeed to see your routing table? Type "netstat -rn". The entry with the G 4352490Sjkhflag is your gateway. 4362490Sjkh -- Dru <genesis@istar.ca> 4372490Sjkh% 4382490SjkhNeed to see which daemons are listening for connection requests? Use 4392490Sjkh"sockstat -4l" for IPv4, and "sockstat -l" for IPv4 and IPv6. 4402490Sjkh -- Dru <genesis@istar.ca> 4412490Sjkh% 442174422SdougbCan't remember is you've installed a certain port or not? Try "pkg_info | 443174422Sdougbgrep port_name". 4442490Sjkh -- Dru <genesis@istar.ca> 4452490Sjkh% 446174422SdougbGot some time to kill? Try typing "hangman". 447174422Sdougb -- Dru <genesis@istar.ca> 4482490Sjkh% 4492490SjkhTo erase a line you've written at the command prompt, use "Ctrl-U". 4502490Sjkh -- Dru <genesis@istar.ca> 4512490Sjkh% 4522490SjkhTo repeat the last command in the C shell, type "!!". 4532490Sjkh -- Dru <genesis@istar.ca> 4542490Sjkh% 4552490SjkhNeed to quickly empty a file? Use "echo > filename". 4562490Sjkh -- Dru <genesis@istar.ca> 4572490Sjkh% 4582490SjkhTo see all of the directories on your FreeBSD system, type 459174422Sdougb 460174422Sdougb ls -R / | more 461174422Sdougb -- Dru <genesis@istar.ca> 462174422Sdougb% 463174422SdougbTo see the IP addresses currently set on your active interfaces, type 4642490Sjkh"ifconfig -u". 4652490Sjkh -- Dru <genesis@istar.ca> 4662490Sjkh% 4672490SjkhTo see the MAC addresses of the NICs on your system, type 4682490Sjkh 4692490Sjkh ifconfig -a 4702490Sjkh -- Dru <genesis@istar.ca> 4712490Sjkh% 4722490SjkhYou can save your kernel startup configuration with kget(8). The 4732490SjkhConfiguration can be edited at boot time with 'boot -c' command in loader. 4742490SjkhSee boot(8), loader(8) for details. 4752490Sjkh% 4762490SjkhYou can open up a new split-screen window in (n)vi with :N or :E and then 4772490Sjkhuse ^w to switch between the two. 4782490Sjkh% 4792490Sjkhsh (the default bourne shell in FreeBSD) supports command-line editing. Just 4802490Sjkh``set -o emacs'' or ``set -o vi'' to enable it. 4812490Sjkh% 4822490SjkhWhen you've made modifications to a file in vi(1) and then find that 4832490Sjkhyou can't write it, type ``<ESC>!rm -f %'' then ``:w!'' to force the 4842490Sjkhwrite 4852490Sjkh 4862490SjkhThis won't work if you don't have write permissions to the directory 4872490Sjkhand probably won't be suitable if you're editing through a symbolic link. 4882490Sjkh% 4892490SjkhIf you want to quickly check for duplicate package/port installations, 4902490Sjkhtry the following pkg_info command. 4912490Sjkh 4922490Sjkh pkg_info | sort | sed -e 's/-[0-9].*$//' | \ 493119470Sceri uniq -c | grep -v '^[[:space:]]*1' 4942490Sjkh% 4952490SjkhWant to use sed(1) to edit a file in place? Well, to replace every 'e' with 4962490Sjkhan 'o', in a file named 'foo', you can do: 497174422Sdougb 498174422Sdougb sed -i.bak s/e/o/g foo 499174422Sdougb 500174422SdougbAnd you'll get a backup of the original in a file named 'foo.bak', but if you 5012490Sjkhwant no backup: 5022490Sjkh 5032490Sjkh sed -i '' s/e/o/g foo 5042490Sjkh