Praji’s Weblog

Welcome to praji’s world


leave a comment »

=> TEXT Editor

# Mode Change i - insert mode ESC - exit insert mode ZZ - save and quit :wq - save and quit :q! - quit without saving # Navigation h - left j - down k - up l - right $ - end of line 0 - beginning of line # Text Modification dw - delete the current line yy - copy the current line p - paste the buffer below the current line

=> Disk Basics

Naming the disk DEVICE ad ATA da SCSI fd FLOPPY DISK SLICE s1 Slice1 Similar to partition in Linux s2 Slice2 PARTITIONS a hda1 ad0s1a / b hda2 ad0s1b swap d hda3 ad0s1d /tmp e hda4 ad0s1e /var f hda5 ad0s1f /usr g hda6 ad0s1g /backup h hda7 ad0s1h /home Listing the Disk # fdisk ad0 Mounting and Unmounting (Default file system in UFS) # mount /dev/ad0s1g /mnt/home # umount /mnt/home Disk Usage # df -h

=> Handling Network

Configuring IPs Setting Default IP # ifconfig rl0 IP Adding IP alias # ifconfig rl0 IP netmask alias This can be done using the file /etc/rc.conf by appending the line as below ifconfig_ETH=”inet IP netmask MASK” ifconfig_ETH_alias0=”inet IP netmask MASK” ifconfig_ETH_alias1=”inet IP netmask MASK” ETH : rl0(RealTek), fxp1(Intel XPro), sis1(Silicon) # /etc/netstart This command restarts the network Some important network configuration files # /etc/hosts (Hostname) # /etc/services (Service names) # /etc/resolv.conf (Resolver IP) # /etc/host.allow (Allow IP list)

=> Ports/Packages

FreeBSD ports are the best software collections that can be installed very easily and efficiently. The packages are found in the folder /usr/ports/ Eg:- wget Finding the location of a port. # cd /usr/ports # make search name=wget Installing softwares using ports. # cd /usr/ports/ftp/wget # make install clean Uninstalling softwares using ports. # make deinstall PACKAGES (Works similar to yum, rpm in Linux Servers) Eg:- exim Download the package from Installing using pkg_add # pkg_add exim4.69.tgz Deleting using pkg_delete # pkg_delete exim4.69 All packages' information is stored in the folder /var/db/pkg Upgrading the ports # portupgrade PKG_NAME Or # portmanager PKG_NAME

=> Firewall

IPFW : IPFirewall IPFW is the basic firewall of FreeBSD Enabling Firewall Add firewall_enable=”YES” in /etc/rc.conf Rule set Firewall rule set is in the file /etc/rc.firewall Commands Basically command follows this syntax C R A L S C: Command add R: Rule Num A: Action allow, accept, pass, permit deny, drop L: Log (/var/log/security) S: Selection It has many sub parts and is given in the next slide. SELECTION Protocol: (/etc/protocols) tcp, udp, icmp From Source to Destination: from SRC to DST SRC/DST : any, me,, Port number: (/etc/services) Chain: in, out Route: via INF INF (Interface): rl0, fxp2 Session: setup Match state: keep-state A simple rule can be as follow: # ipfw -q add 123 deny tcp from to me 80 in via rl0 keep-state Listing the Firewall rules. # ipfw list Flushing the rules # ipfw flush All the rules can be gathered in a script and can be stored in /etc/ipfw.rules #!/bin/sh cmd="ipfw -q add" if=rl0 ks="keep-state" ipfw flush $cmd 100 deny from to me in via $if $ks

=> Miscellaneous

SHELLS Default shell of FreeBSD is C shell(.chshrc, .chsh_history are the shell files). The environmental variables are set as follows. # setenv JAVA_HOME “/usr/local/jdk” To change the shell # chsh -s /usr/local/bin/bash # echo "/usr/local/bin/bash" >> /etc/shells # chsh CRONS # crontab -l Crons are found in the folder /etc/periodic/ User crons are loacted in the folder /var/cron/tabs/ EDITING PASSWORD FILE For editing password file in FreeBSD we use vipw # vipw # pwd_mkdb CHANGING ATTRIBUTES (similar to lsattr, chattr in Linux) # chflags ATTRIB FILENAME ATTRIB: schg/noschg immutable sunlnk/nosunlnk undeletable Check this attributes by ls -lo STARTUP SCRIPTS The basic service scripts are in the folder /etc/rc.d/ and the applications loaded later like apache, exim etc. have their startup scripts in /usr/local/etc/rc.d/ ADDING LINUX COMPATIBILITY a) Enable Kernel Loadable Module (KLD) # kldload linux b) Append linux_enable="YES" in /etc/rc.conf c) Install Linux runtime libraries # cd /usr/ports/emulators/linux_base-fc4 # make install clean


Written by praji

June 28, 2008 at 4:27 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: