FreeBSD notes bsd.jpg
CVSup kernel compilation
burning a CD/DVD CDRW/DVDRW Format
samba firewall
iso DVD Video Stuff
misc commands Mount
X configuration Time
MySQL Apache
Ports Mplayer
cron Portupgrade
ssh Permissions
scripts newspost
Home_box perl threaded
conf NIC/ifconfig

Many thanks goes out to Whiz Peterson!  He is the ZENmaster of all things FreeBSD.




CVSUP
Cvs up is the process whereby the base OS and the ports tree can be updated automagically..
Do a little /stand sysinstall to get cvsup without gui going and to add the system sources..

Here is how you do the cvsup thing:
/usr/local/bin/cvsup -g -L 2 /etc/cvsupfile

SAMPLE CVSUPFILE
*default host=cvsup2.FreeBSD.org
*default base=/usr
*default prefix=/usr
*default release=cvs tag=RELENG_5_3  (for the 5.3 release)
*default delete use-rel-suffix

*default compress
src-all
*default release=cvs tag=.
ports-all


buildworld

I usually add to my kernel config file:
CP GENERIC BEASTIE
edit BEASTIE like so...
:%s/GENERIC/BEASTIE/g
Delete all but the i686 in the cpu section
I usually add at the bottom
*****I usually get the sound going with a script....
**** I maybe moving to PF as the firewall of choice.
device    pcm
options   IPFIREWALL
options      IPFIREWALL_VERBOSE

TV Card
    device bktr
    device iicbus
    device iicbb
    device smbus
for my ati tv wonder ve I had to edit sysctl.conf...
sysctl hw.bt848.tuner=5

Building the World and recompiling at the same time!
make buildworld && make buildkernel KERNCONF=BEASTIE && make installkernel KERNCONF=BEASTIE && make installworld && mergemaster && reboot
This is done in /usr/src  


Firewall

in root/firewall.rules
#this allows for everthing coming in to get back out aka related established
add 100 allow all from any to any via lo0
add 1000 allow all from me to any keep-state
#This allows all incoming SSH
add 1100 allow tcp from any to me 22 keep-state
#This allows all incoming port 80
add 1200 allow tcp from any to me 80 keep-state

in etc/rc.conf put this....
firewall_enable="YES"
firewall_type="/root/firewall.rules"

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firewall Bridge

add 100 allow all from any to any via lo0
add 1000 allow all from me to any keep-state
add 1010 allow all from 162.114.80.0/24 to any
add 1100 allow tcp from any to me 22 keep-state
add 1200 allow tcp from any to me 80 keep-state
add 1250 allow all from any to any in via xl0 keep-state
add 1275 deny all from any to me in via xl1
add 1300 deny all from any to any via xl1 bridged

Kernel Options:
options BRIDGE
options      IPFIREWALL_DEFAULT_TO_ACCEPT

/etc/sysctl.conf
net.link.ether.bridge=1
net.link.ether.bridge_cfg=xl0,xl1
net.link.ether.bridge_ipfw=1


Mount

Mounting windows box
mount_smbfs  -I 10.10.10.111  -W chs //username@server/share /mnt/folder

Mounting a usb key
mount_msdosfs /dev/da0s1 /mnt/usb



NIC

I usually use /stand/sysinstall to configure the nic  here is how to add the defualt route:

route delete default
route add default IP_ADDRESS




MISC

rsync -rP <filename> user@172.11.11.101:/the/path

Kill a process
killall NAME OR
kill -9 "Process ID" aka PID

chmod 777 /dev/acd0c
this will allow like mplayer to read off your dvd's...  and some cd audio??
 when adding a user if you give the user the uid of 0 it is the same as making that user root.  You can change the uid wit a litte vim /etc/passwd

do this to update the locate database
/usr/libexec/locate.updatedb &

UPTIME
So you wanna know how long your box has been running
uptime

turn  off the bell for all xwindows applications.
xset -display :0 b off

chsh   changes your shell

Forwarding Mail:
edit /etc/mail/aliases
uncomment root:  me@my.domain   Change to something like this....
# Pretty much everything else in this file points to "root", so
# you would do well in either reading root's mailbox or forwarding
# root's email from here.
root:   yeremail@duh.com
Save and run this command
newaliases

Unzip
unzip -d pencil pencil.zip will extract the zipped file pencil into a directory called pencil

BASH help for ky.gov proxy silliness
export HTTP_PROXY=http://publicserver:23
export FTP_PROXY=http://publicserver:23


TCPDUMP
tcpdump -i bge1 src host 172.26.23.35 and dst port 445
This is just a sample something blasting out port 445 traffic, like a virus or something.


Formatting a new Drive

Go into /stand/sysinstall
do the fdisk thing
do the label thing
then

newfs -O 2 -U /dev/ad7s1

Linking
ln -s newfile  oldfile
aka ln -s atk.so.600 atk.so.399

Running stuff as ROOT in an xwindow
xhost +
(xhost - undoes this)

finding and deleting by filename search
find . -iname "*par2" -exec rm -f \{\} \;

Grip
--alt-preset standard %w %m

VI
dd to del the a line
yy to cp the c line
p to paste the c line
r to replace the c to an a
cw (change word)

ISO

Making an iso
dd if=/dev/acd0c of=/test bs=2048

Burning a CD ISO image
burncd -s max data ISOFILENAME.ISO && burncd fixate

burning a DVD ISO
growisofs -dvd-compat -speed=2 -Z /dev/cd0=ISOFILENAME.ISO

.bin .cue
Converting a .bin and .cue to an iso
bchunk file.bin file.cue  newfile.iso


X Configuration

Do this:
XFree86 -configure OR    Xorg -configure
this creates this file:
XF86Config.new
copy this file:
cp /root/XF86Config.new /etc/X11/XF86Config
      OR

cp /root/xorg.conf.new  /etc/X11/xorg.conf


Edit this:
Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Monitor Vendor"
        ModelName    "Monitor Model"
        HorizSync    30-107
        VertRefresh  48-120
**** the HorizSync and VertRefresh Lines need to be added...
XORG DOES A GOOD JOB OF DETECTING THIS....



Edit this as well

Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
------->DefaultDepth 24
      

    SubSection "Display"
                Depth     24
------------->  Modes     "1024x768"
        EndSubSection
EndSection

Section "InputDevice"
    Identifier  "Mouse0"
    Driver      "mouse"
    Option      "Protocol" "auto"
    Option      "Device" "/dev/sysmouse"
--> Option      "ZAxisMapping"  "4 5"
EndSection
=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Install from ports...

/usr/ports/x11-fonts
    artwiz-fonts
    freefonts
    sharefonts
    mozilla-fonts
    urwfonts
    webfonts

In XF86config....


Section "Files"
    RgbPath      "/usr/X11R6/lib/X11/rgb"
    ModulePath   "/usr/X11R6/lib/modules"
    FontPath     "/usr/X11R6/lib/X11/fonts/URW/"
    FontPath     "/usr/X11R6/lib/X11/fonts/artwiz-fonts/"
    FontPath     "/usr/X11R6/lib/X11/fonts/freefont/"
    FontPath     "/usr/X11R6/lib/X11/fonts/mozilla/"
    FontPath     "/usr/X11R6/lib/X11/fonts/sharefont/"
    FontPath     "/usr/X11R6/lib/X11/fonts/webfonts/"
    FontPath     "/usr/X11R6/lib/X11/fonts/misc/"



-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Install either KDE or GNOME   OR XFCE which is kind of kewl.

------->   /usr/ports/x11/gnome2

The handbook is the bomb as far as how to do this...
 
**********
KDE
echo "exec startkde" > ~/.xinitrc
**********************************
GNOME
echo "/usr/X11R6/bin/gnome-session" > ~/.xinitrc
**********************************************
XFCE
echo "/usr/X11R6/bin/startxfce4" > ~/.xinitrc
***************************************

To do the graphical automagic GNOME logon go here:
/etc/ttys
ttyv8   "/usr/X11R6/bin/gdm -nodaemon"  xterm   on secure
___________________________________________________________________________________________
MODIFY your /etc/hosts to shut up the graphical login nag about finding the hostname.

time

do this:
/etc/ntp.conf
server gilbreth.ecn.purdue.edu
restrict 127.0.0.1
restrict default ignore

in /etc/rc.conf add this:
xntpd_enable="YES"
do this:
ntpd
**I have an ntp.conf file on my ftp site, just grab it.

MySQL

Install MySQL40 from the ports, take the defaults

Starting the mysql dude in FreeBSD!
/usr/local/etc/rc.d/mysql-server.sh start


Apache

Install Apache13 from the ports, take the defaults

Install mod_php4 from the ports.
Select these options:
BCMATH
BZIP2
FTP
GD
MCRYPT
MHASH
NCURSES
OPENSSL
PDFLIB
PSPELL
SOCKETS
ZIP

It does select MYSQL and other things,  leave them alone.  We definately need the MYSQL
___________________________________________________________________________________________
Configuring Apache to use PHP:
look in /usr/local/etc/apache/
Edit httpd.conf
THis needs to be there, it may already be there..LoadModule php4_module libexec/apache/libphp4.so
as well as AddModule mod_php4.c

For users to server pages... Uncomment the section that is like this <Directory /home/*/public_html>


/usr/local/etc/rc.d/apache.sh start
This will start the apache server....


Now create the public_html folder with each users home folder....
chown dltucker public_html

__________________________________________________________________________________________
Creating HOST Headers....

Checkout the changes to my /usr/local/etc/apache/httpd.conf file
for the virtual host settings
Aaron also created a folder for the virtual hosts  aka /usr/local/etc/apache/vhosts
within here go all of the files that create your virtual hosts..

Ports

*************install portupgrade first then do:
portupgrade -N bash2 vim nmap etc...

BASH2 Shell
Vim
Nmap
Ethereal
Gimp
GPDF
Gnomesword
Sword
Sword-modules
Pan
newspost
NCFTP3
Dict
CowSay
IRSSI
sudo
MySQL40*
Apache13*
mod_php4*
Links
GFTP
edna
AbiWord
Firefox
Wget
Xmms
Portupgrade*
Samba*
grip
easytag

*see Further Notes in the Document for Specific Install Options


mplayer

INSTALL From the ports!

Playing a dvd is something like this:
mplayer dvd:// /dev/acd0

playing an iso file is like this:
mplayer dvd:// -dvd-device sharktale.iso

I think had to do some of this:
ln -sf /dev/acd0 /dev/dvd
and this:
chmod 666 /dev/acd0

SETTING THE AUDIO TO ENGLISH
-aid 128


DVD

VOBCOPY 
mount the dvd
vobcopy -i /cdrom -t FOLDERNAME -m

Copy Dvd's with mplayer
(this assumes the following are installed:  mplayer, vobcopy,cdrtools,mjpeg tools WITHOUT_QT=YES, transcode, dvdauthor)

Mount the dvd
then
mplayer dvd:// -dvd-device /cdrom -dumpaudio -dumpfile dvd.mpa && mplayer dvd:// -dvd-device /cdrom -dumpvideo -dumpfile dvd.m2v
then (this takes the two extracted files (audio/video) and slaps em into dvd compatable mpg file)
mplex -f 8 -o dvd.mpg dvd.mpa dvd.m2v

then
dvdauthor -o FOLDERNAME -x dvd.xml   (this creates the dvd file system, vobs, etc.dvd.xml is a kewl script from whiz..)

then(MUST BE root to use growisofs)
 growisofs -dvd-compat -dvd-compat -speed=2 -Z /dev/cd0 -dvd-video FOLDERNAME

(this burns it to dvd!)
***********************SHRINKING A Ripped DVD that's 2 Big******
mplayer dvd:// -dvd-device /usr/filez/beauty-beast -dumpaudio -dumpfile dvd.mpa && mplayer dvd:// -dvd-device //usr/filez/beauty-beast -dumpvideo -dumpfile dvd.m2v

FIND out which title to grab!!

______________================================___________________
tcrequant -i dvd.m2v -o dvd222.m2v -f 1.5
Shrinks the ole video by a factor of 1.5
_________________________________________________________________
GRABBING Chapter Info
/chapters2.pl /media/constantine/constantine/ 1
*******make sure the full path the video is used when grabbing chapters..
THis grabs the chapter info out of what is vob copied.

PASTE this into the dvd.xml file like..

<vob file="dvd.mpg"
chapters="00:00:00.000,00:02:48.066,00:06:42.933,00:10:32.600,00:14:20.733,00:17:58.766,00:20:30.066,00:24:29.900,00:27:20.900,00:29:40.400,00:34:19.933,00:37:33.767,00:41:16.100,00:46:47.067,00:50:26.233,00:53:30.566,00:57:59.899,01:01:21.399,01:04:28.566,01:09:13.433,01:12:19.900,01:16:01.567,01:18:25.733,01:22:31.899,01:25:45.566,01:29:46.599,01:34:00.099,01:37:02.066,01:39:53.232,01:42:51.398,01:44:57.398,01:48:21.431,01:51:23.098,01:53:46.231"
/>

cron

as root (or maybe a regular user..?)
crontab -e
0 1 * * * /usr/libexec/locate.updatedb &
0 2 * * * /usr/local/bin/cvsup -g -L 2 /etc/cvsupfile

This will update that locate database at 1am and run cvsup at 2am.



Samba

Install Samba from the ports..
actually do the samba-devel version as according to the whiz it works best for XP
edit smb.conf in this folder  /usr/local/etc

Put something like this in the WINS server location  162.114.200.270

Check out my smb.conf file on the ftp site..   This is to allow it to be a file server..
samba_enable="YES"   in rc.conf

/usr/local/etc/rc.d/samba.sh start  will get er done

smbpasswd -a USERNAME

So here is the deal.   Samba needs a unix account, that is really how permissions other than read only
are granted.


portupgrade

Make sure BASH is installed  do the proxy export thingy if at work..

/usr/ports/make fetchindex

Install from ports:
/usr/ports/sysutils/portupgrade

** Make sure that you install bash
do the export proxy thing.
make fetchindex in /usr/ports

Then do this:
 portsdb -uU && pkgdb -F

THis updates what is installed   do this after every cvsup think CRON

portupgrade -aRr

this will update everything that I have installed from ports to the latest flavor  running services will need to be restarted to get the changes.


portversion will let you know what needs to be upgraded
=  means current
<  is not current
>  ocassionally this will be for wacky new stuff outside the portsystem
*  Not available in ports but it is installed
========================================================================
Backing up installed ports

pkg_version > packages.txt

tar up /etc
tar up /usr/local/etc
tar up /home
tar up an

XARGS
cat packages.txt | xargs portupgard -N -F y stuff that you have added and don't have on cd (ie. mp3's, etc..)

ssh

ssh with keys
first at your machine do this
ssh -keygen -t rsa
then...
$ ssh server "mkdir .ssh; chmod 0700 .ssh"
$ scp .ssh/id_rsa.pub server:.ssh/authorized_keys2
http://hacks.oreilly.com/pub/h/66

   
permissions

find old_public_html -type d -exec chmod 755 \{\} \;
find old_public_html -type f -exec chmod 644 \{\} \; The first part of like 755  is Owner  Group World
so 755  would be owner full control group and world read/execute

0=no access
1=execute
2=write
4=read

7=read-write-execute
6=read-write
5=read-execute
4=readonly
3=write-execute(never seen this)
2=write (not seen this)
1=execute(not seen this)
0=no access is used sometimes


Scripts

using a script to determine the correct sound module
in this folder
/boot/kernel
for f in snd_*; do kldload $f; done
this loads all of the sound modules.

start xmms

then do this:
for f in snd_*; do kldunload $f; done
now we need to do kldstat to see which one is the correct one.
go to /boot
edit loader.conf with somehting like this...
snd_maestro3_load="YES"

DVD2Divx  Script
dvd2divx 1 /cdrom paul.avi

Flac Script
for f in *; do flac -d "$f"; done

Mac Script
for f in *.ape; do mac "$f" "$(basename $f .ape).wav" -d; done

Mp3 Script
for f in *; do lame --decode "$f"; done


newspost


 newspost -d -i localhost -u freebsd4life -p "*******" -f "fred@pd.net" -F Ed -n alt.binaries.sounds.mp3.complete_cd -s "plz post Lifehouse-Stanley Climbfall" -y *

-d = defaults
-i = the server to use
-u = yer username
-p = yer password
-f = yer email
-F = yer name
-n = the newsgroup you are posting to
-s = subject
-y = use yencoding cause Whiz says so
*  = posts all files in the current directory


afterwords if you want to post to the same group just do the -s and * if you are in the directory that you want to post.

JUST USE PAN if you just want to request something...

Home_box

Loader.CONF   for my Home Box 5.3
hint.acpi.0.disabled=1
linux_load="YES"
nvidia_load="YES"
snd_es137x_load="YES"
hw.ata.atapi_dma="1"


Burn Commands

DVD
growisofs -dvd-compat -Z /dev/cd0 (my home box)  -J -R /FOLDERNAME
growisofs -dvd-compat -Z /dev/cd0  -J -R -joliet-long /FOLDERNAME

device atapicam needs to be in the kernel and it needs to be recompiled as well as  hw.ata.atapi_dma="1" in the old loader.conf

CDR
Burncd
mkisofs -J -r FOLDERNAME? | burncd -s max data - && burncd fixate
this burns the  folder to a cdr.   dig it.

Burning CD ISO
burncd -s max data ISOFILE.ISO && burncd fixate

burning a DVD ISO
growisofs -dvd-compat  -speed=2 -Z /dev/cd0=isofile.iso

burning a DVD movie folder
growisofs -dvd-compat -speed=2 -Z /dev/cd0 -dvd-video FOLDERNAME


Burning CD Audio
CD paranoia to copy an audio cd
cd /media/cdcopy
cdparanoia -d /dev/cd0 -B -- "1-"
cdrecord -dev=1,0,0 -v speed=10 driveropts=burnfree -pad -audio *.wav

the dev options requires that you run cdrecord -scanbus to find out which device is your burner,  what this does is copy the tracks from device cd1 to wav files in the /media/cdcopy folder
the it uses cd record to burn them to audio.



Format Commands

to FORMAT my DVD-RW.....
 dvd+rw-format -blank=full /dev/cd0

FORMATTING A CDRW
 burncd -f /dev/acd0 blank


threaded perl

to install threaded perl:

cd /usr/ports/lang/perl5.8
make PREFIX=/opt/perl5.8-threaded WITH_THREADS=yes cd work/perl-5.8.7 make
install cd ../BSDPAN-5.8.7 mkdir
/opt/perl5.8-threaded/lib
/perl5/5.8.7/BSDPAN
cp -R * /opt/perl5.8-threaded/lib/perl5/5.8.7/BSDPAN/

To install modules via CPAN:

/opt/perl5.8-threaded/bin/perl -MCPAN -e shell

I mostly take defaults for CPAN.
I set a proxy if I'm setting it up at work.
I usually try to set up pair.com as the first mirror with a few other
secondary mirrors since Pair Networks has good bandwidth.
I usually install Bundle::CPAN when it recommends I do so.

i /search_term/
install My::Module

change #!/usr/bin/perl on the first line of nzbperl.pl to:

#!/opt/perl5.8-threaded/bin/perl


conf

.bashrc
PS1="[\t][\u@\h:\w]\$ "
alias startx="startx -listen_tcp"
PATH=$PATH:/usr/scripts

.vimrc
syntax on
colorscheme desert
set tabstop=4
set ruler
set backspace=eol,start,indent
set nocompatible
set autoindent
set smartindent
set shiftwidth=4
set vb t_vb=
set incsearch

Document made with Nvu