Find a string in a file
How to search for a string in a selection of files (-exec grep ...).
I've used this method a few times to find a file that I created a while back but can't remember the name. But I do remember some of the source code in that file.
NOTE: # is the command line
# find . -exec grep "function getUserIP" '{}' \; -print
// another good example is to only search by file name, in this case, only look at .php files
# find . -name '*.php' -exec grep "function getUserIP" '{}' \; -print
Unable to connect to CUPS server localhost:631 – Connection refused
Jul 1 10:47:01 xxx smbd[791]: [2008/07/01 10:47:01, 0] printing/print_cups.c:cups_connect(69)
Jul 1 10:47:01 xxx smbd[791]: Unable to connect to CUPS server localhost:631 - Connection refused
For those seeing the same error, it's apparently solved by adding this line to [global]: inside the smb.conf file
printcap name = /etc/printcap
Update Ports tree on FreeBSD
With every new FreeBSD install, it's always nice to update the ports tree found in /usr/ports. This way you always install the newest software and not something that may have bugs.
This is the way I've been doing it that I've found has always worked the quickest.
NOTE: # means what you type in at the command line
// As root install cvsup without gui (command line version)
# pkg_add -r cvsup-without-gui
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-7.3-release/Latest/cvsup-without-gui.tbz... Done.
#
//create file in /root/cvs-supfile and put the following text between --------cvs-supfile--------
// also change src-all tag=RELENG_7_0 to which ever FreeBSD version you have.
#vi /root/cvs-supfile
--------cvs-supfile--------
*default host=cvsup.ch.FreeBSD.org
*default base=/usr
*default prefix=/usr
*default release=cvs
*default delete use-rel-suffix
*default compress
src-all tag=RELENG_7_0
ports-all tag=.
--------cvs-supfile--------
//create a file called refuse and copy the text between --------- /usr/refuse --------- into it.
// What this does it tell cvsup-without-gui not to include these ports in the update.
// Most of the time we won't need this stuff... but if you think you will, just remove it from the refuse file or simply comment it out by adding a # in front of the line
# vi /usr/refuse
--------- /usr/refuse ---------
ports/arabic
ports/astro
ports/audio
ports/biology
ports/cad
ports/chinese
ports/finance
ports/french
ports/german
ports/hebrew
ports/hungarian
ports/japanese
ports/math
ports/korean
ports/palm
ports/polish
ports/portuguese
ports/russian
ports/ukrainian
ports/vietnamese
doc/da_*
doc/de_*
doc/el_*
doc/es_*
doc/fr_*
doc/it_*
doc/ja_*
doc/nl_*
doc/no_*
doc/pl_*
doc/pt_*
doc/ru_*
doc/sr_*
doc/zh_*
--------- /usr/refuse ---------
// Run cvsup file and tell it to use the file in the root directory
# rehash
# cvsup -g -L 2 /root/cvs-supfile
// about 30-60 minutes later your ports tree will be up to date
// for extra help, visit http://www.freebsd.org/doc/en/books/handbook/ports-using.html