FreeBSD: Difference between revisions

From The Incoherency.Net Wiki
Jump to navigation Jump to search
Denis (talk | contribs)
Denis (talk | contribs)
Line 159: Line 159:
=== List BIND Domains ===
=== List BIND Domains ===


  grep ^zone < /etc/namedb/named.conf | sed -e 's/zone "\(.*\)" {/\1/g' | sort
  grep ^zone < /etc/namedb/named.conf | sed -e 's/zone "\(.*\)".*/\1/g' | sort

Revision as of 17:15, 17 July 2008

http://www.denis.lemire.name/images/posts/freebsd.png

Essential Ports

ftp/wget

  • Retrieve files from the Net via HTTP and FTP

misc/gnuls

I miss the colorized output of ls seen on most Linux systems... Installing the gnuls port and adding the following to /etc/csh.cshrc will add this missing convenience to FreeBSD:

alias ls        gnuls --color=auto -h

net-mgmt/net-snmp

  • An extendable SNMP implementation

net/tcpick

tcpick is a textmode sniffer libpcap-based that can track, reassemble and reorder tcp streams. Tcpick is able to save the captured flows in different files or displays them in the terminal, and so it is useful to sniff files that are transmitted via ftp or http.

For example, to intercept and view a POP3 login via the rl1 interface, use the following command:

tcpick -i rl1 -p -bU -T1 "port 110"

ports-mgmt/portaudit

Checks ports against a list of security vulnerabilities. Also adds a daily periodic job to include vulnerabilities in currently installed ports in the daily security e-mail.

To disable checking ports again portaudit during installation set the environment variable as follows:

DISABLE_VULNERABILITIES=yes

ports-mgmt/portupgrade

Portupgrade is a tool to upgrade installed packages via ports or packages. You can upgrade installed packages without having to reinstall depending or dependent packages. It can automatically trace dependency chains up and down upgrading packages recursively.

This package also includes the following utilities:

  • portinstall - Helps you install new ports in a handy way.
  • portcvsweb - Instantly lets you browse change history via CVSweb.
  • portversion - Replaces pkg_version(1) and helps you upgrade packages with portupgrade(1). (runs much faster)
  • portsclean - Cleans ports workdir's, unreferenced distfiles, old and orphan shared libraries, and stale packages.
  • portsdb - Creates binary database from the ports INDEX.
  • ports_glob - Expands ports globs.
  • pkg_deinstall - Wraps pkg_delete(1) and provides additional features.
  • pkg_fetch - Fetches packages from a remote site.
  • pkg_glob - Expands package globs.
  • pkg_which - Checks which package a file came from quickly.
  • pkgdb - Manages and searches the package database.

Example: Rebuild OpenSSL and all packages that depend on it:

portupgrade -rfx openssl openssl

security/sudo

  • Allow others to run commands as root

sysutils/screen

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).

Screen is extremely handy for running commands that may take an extended time to complete. One can start a command, close their terminal and later re-attach another terminal to their session without interrupting the command(s) that are completing.

It can be also used to attach multiple users to a single screen session to allow easy collaboration.

sysutils/smartmontools

Adds S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) disk monitoring tools. This suite of tools is extremely handy to allow the administrator to be aware of disk problems before they result in a catastrophe.

See the following links for more information:

Example commands:

  • smartctl -l selftest /dev/ad0
  • smartctl -t long /dev/ad0
  • smartctl -Hc /dev/ad0

Technical Notes

Disk image via dd

dd bs=512 if=/dev/rXX# of=/some_dir/foo.dmg conv=noerror,sync

tar over netcat

  • nc -v -v -w 40 -l -p 8888 > foo.tar
  • tar cjvf * | nc remotehost 8888

Updating root DNS

dig @a.root-servers.net . ns > /etc/namedb/named.root

Qmail log Timestamps

Can be converted to human readable using the tai64nlocal command.

Name Services

Retrieving Database Entries

As of FreeBSD 7 the getent utility can be used to retrieve entries from the various administrative databases.

Name Service Caching Daemon

The nscd daemon added in FreeBSD 7 improves performance of nsswitch type lookups (users, groups, etc) but can cause some surprising results with new users not being found in the system. The cache can be cleared for all users by running:

%nscd -I cachename

Using IDE CD Burners

Place the following in /boot/loader.conf for IDE CDRW support:

atapicam_load="YES"
hw.ata.atapi_dma=1

Using Memory Disks

FreeBSD >= 5.x have a memory disk utility that can be utilized to mount file system images.

To setup a memory disk

mdconfig -a -t vnode -o readonly -f /path/to/image.iso -u 1
mount -t cd9660 /dev/md1 /mnt/cdrom

To reverse the process:

mount -u /mnt/cdrom
mdconfig -d -u 1

Berkeley Vi Customization

The clone of Vi included in the FreeBSD base system is Berkeley Vi (nvi). The following can be added to ~/.nexrc to enable auto-indentation and automatic line wrapping:

set autoindent
set wraplen=78

Displaying Dates in 12 Hour Format

Add the following to .cshrc or /etc/csh.cshrc (system wide):

alias date date +\"%a %b %e %r %Z %Y\"

View Daylight Savings Dates

zdump -v /etc/localtime | grep 2008

List BIND Domains

grep ^zone < /etc/namedb/named.conf | sed -e 's/zone "\(.*\)".*/\1/g' | sort