Handy OpenBSD Commands

Recently we setup a server called Bryan here is the PDF of the transcript of the installation


These commands and hints are arranged in no particular order

basic Unix commands

using the VI (vi) text editor

full description of all VI commands

installing the nano text editor

common server commands

Configuring Apache (httpd) web server

tar archiving and storage

Daemons killing, starting, restarting, reconfiguring

Appletalk (netatalk installation)

Contributing to SETI

Windows networking (SAMBA installation)

Setting up the use of distant proxy servers eg Department of Education and Training


Basic Unix commands:

To get full documentation on all of these commands, type

man <command> eg man finger

where <command> is replaced with one of the following


to show you how long the server has been up, load averages, and who is logged in and what they are doing.


eg finger richard@narromine.com

is similar to w but can be used to see what people are doing on remote servers without logging in


gives you a list of files in the current directory

ls -al

gives a more detailed listing of files including permissions

ps -aux

shows all processes or jobs running on the server and their PID's or Process ID's (usefull when u need to kill a job)


shows you which processes are using the most cpu time, and memory resources


this is like the dos copy command and is used to copy files you can specify absolute paths this is often handy


removes files or deletes them (Warning - this operation is final, no second changes!)

rm -r

can be used to remove directories or collections of files without further questioning (very powerfull)


eg less index.html

This is used to view the content of files (use q to get out of it)

| (pipe)

or "shift \" on most keyboards, is used to pipe the output from one application into another, for example try this

ls -al | less

This will allow you to browse through a long list of files using the less command set

telnet eg telnet narromine.com

Is the traditional way of logging in to remote servers, this method does not encript the packets sent, hence making it insecure a better way of logging into remote sites is with the ssh command

ssh narromine.com

Uses a Secure Shell to make the connection which encrypts trffic before sending it.


top vi filename

To start editing a file, enter the command "vi file_name<carriage-return>". The command you should enter as soon as you start editing is ":set verbose show- mode<carriage-return>". This will make the editor give you verbose error messages and display the current mode at the bottom of the screen.

The commands to move around the file are:

h Move the cursor left one character.

j Move the cursor down one line.

k Move the cursor up one line.

l Move the cursor right one character.


The cursor arrow keys should work, too.


Search for the string ``text'' in the file, and

move the cursor to its first character.

The commands to enter new text are:

a Append new text, after the cursor.

i Insert new text, before the cursor.

o Open a new line below the line the cursor is on,

and start entering text.

O Open a new line above the line the cursor is on,

and start entering text.


Once you've entered input mode using the one of the

a, i, O or o commands, use <escape> to quit enter-

ing text and return to command mode.

The commands to copy text are:

yy Copy the line the cursor is on.

p Append the copied line after the line the cursor is


The commands to delete text are:

dd Delete the line the cursor is on.

x Delete the character the cursor is on.

The commands to write the file are:


Write the file back to the file with the name that

you originally used as an argument on the vi com-

mand line.

:w file_name<carriage-return>

Write the file back to the file with the name


The commands to quit editing and exit the editor are:


Quit editing and leave vi (if you've modified the

file, but not saved your changes, vi will refuse to



Quit, discarding any modifications that you may

have made.

One final caution. Unusual characters can take up more

than one column on the screen, and long lines can take up

more than a single screen line. The above commands work

on ``physical'' characters and lines, i.e. they affect the

entire line no matter how many screen lines it takes up

and the entire character no matter how many screen columns

it takes up.

These are the basic vi commands, for power user mode please read the manual with

man vi


top To restart the Apache web server (httpd) use

apachectl graceful

To reload the ipnat rules use

ipnat -CF -f /etc/ipnat.rules

To look for red worm virus attacks, search for default.ida in the web log files found at

cd /var/www/logs/

cat access_log | grep default.ida | wc -l

To rotate log files on a regular basis, say once a day, edit this file


This file is read by the system every hour. To edit it, type

cd /etc/

then type

vi newsyslog.conf

Useful vi commands include a fro add or i for insert, hit esc for a mode change, :wq to write and quite

Top Setting up the use of distant proxy servers eg Department of Education and Training

To get a unix box to use the DET's proxy servers for HTTP use

export http_proxy="http://proxyds.schools.nsw.edu.au:80"

Test with:

ftp http://narromine.com/index.html

and for ftp use

export ftp_proxy="ftp://proxyds.schools.nsw.edu.au:80"

Test with

ftp ftp://narromine.com/mac/test.htm

NOTE: This must be done on every login or added to the .profile file in the users home directory!



To reload the configuration file of any daemon type

kill -HUP PID (where PID is the Process IDentification, which can be obtained using ps -aux)

To actually kill a daemon type

kill -KILL PID

To restart the Domain Name Server (DNS or named) type

named -t /var/named -u named

To change the name of the server, as root type

hostname newname

To start the router daemon type

routed -q

To load SAMBA (windows server) type both

smbd -D

nmbd -D

to load proton chat, as root, type

/usr/local/bin/chatd -u chatd -g chatd -p23



To create an archive (tar ball or tar file) type

tar -cf tar_file_name stuff_to_tar

If you which to use compression and receive feedback on the progress use

tar -Zvcf tar_file_name stuff_to_tar

To expand an archive (tar ball) use

tar -xf filename_to_untar.tar

To expand a compressed tar ball use

tar -xzf filename.tar.gz

To create a symbolic link to another directory type

ln -s directory_to_symlink_to symlink_name

To copy files using ssh (highly recommended) type

scp -r user@host:/path/to/source/file user@host:/path/to/destination/file

note that only one user@host is required if you are already logged into one of the servers.

To mount a floppy disk, you must first mount the drive with

cd /mnt

mkdir floppy

mount /dev/fd0a /mnt/floppy

to mount a CD-ROM use

cd /mnt

mkdir cdrom

mount /dev/cd0a /mnt/cdrom

to specify an msdos formatted floppy use

mount -t msdos /dev/fd0a /mnt/floppy

Port numbers and associated services can be found at

less /etc/services

If you wish to find a file use

locate filename

If you wish to locate the home directory for an application (eg perl) use

whereis perl



To install netatalk (appletalk server) you will need to get the file:

netatalk-1.4b2+asun2.1.3.tar.gz from


expand this file in your directory or in /tmp then modify the Makefile

by replacing ${PREFIX} with /usr/local and ${sysconfdir} with /etc

then make, then install.

You will also need to recompile the kernel

You then need to copy the kernel config file and add the word NETATALK in the appropriate location.

This file can be found at


cp generic newkernel

vi newkernel (a netatalk, ESC, :wq)

cd ../compile/newkernel

make depend && make

cd /

cp /bsd /bsd.old

cp /sys/arch/i386/compile/newkernel/bsd /bsd

the reboot using

shutdown -r now

you can the setup the shares for appletalk by

cd /etc/netatalk/

vi AppleVolumes.default

remember to :wq when finished

Note this file is read everytime a user tries to mount a volume on their mac.

To remove a directory containing files and other directories use

rm -rf directory_name


To make the CPU do usefull things when it sits idle, go to



Setting up samba, go to

cd /usr/ports/net/samba/

then type


wait a while, when ready type

make install

then configure the files in

cd /etc/samba/

good luck, I am still working through this oct 2001

to restart squid use

squid -k reconfigure /usr/local/bin/squid

edit the squid config file to give email access.