Linux Command | OpenBSD Command | Notes |
---|---|---|
route | netstat -r | It is often wise to add -n. That turns off reverse DNS lookups which often don't work when you are playing with routes. (route show also works). |
ifconfig | ifconfig -a | |
ps fxa | pstree | must install it from /usr/ports/sysutils/pstree |
killall | pkill | |
adduser ... | adduser | Run it without parameters for interactive mode instead of specifying everything on the command line. |
OpenBSD uses a 2-layered partitioning system...
The first layer is the standard PC partition table. This is of course required for compatibility with the PC BIOS. This partition table is created using the fdisk command which is similar to the one provided by Linux. Normally only one partition (type A6) is made per disk. During the install one of the first questions asked is if you whish to use the whole disk for OpenBSD. If you answer yes the installer will wipe out the existing partition table and replace it with a single OpenBSD partition allowing you to skip this step completely. This step is also skipped on hardware platforms that already use the BSD disklabel such as SPARC systems.
The second layer is the BSD disklabel. The disklabel allows you to make up to 15 logical partitions (often called slices) within the PC partition. These are what you will format and mount. They use letters (a-p) instead of numbers (the disks themselves are numbered). It is customary that slice a is the root filesystem and slice b is the swap partition. Slice c is a special slice that spans the entire disk and should not be changed (this is the one you use if you want to access the entire disk). Other common filesystems to make slices for are /usr, /var, /home, and sometimes /usr/local. The standard filesystem in OpenBSD is "4.2BSD", also known as ffs, which will be the default choice when making any slice other than b. Note that even if you want to use the entire disk for a single filesystem you should NOT simply format and mount the c slice. You should create another slice that covers the entire disk.
Before you can start using the ports system you must unpack the ports.tar.gz tarball from the last CD into /usr/ports.
Some ports have "flavors" which are simply alternate ways of installing a program. The most common flavor is no_x11 which means to not compile the program with support for X or any GUIs.
Here are the steps to compile and install a program from the ports tree:
When you run these commands ports will go download the source, recurse into any dependencies required by the program you are installing, patch the source if needed, configure the source, compile the source, assemble a binary package, and install the binary package (under /usr/local).
It is also possible to take those binary packages (in /usr/ports/packages) and install them on other OpenBSD systems without the need to compile the same code on every box. To install a binary package directly just use the pkg_add command.
It is also possible to download those binary packages from the OpenBSD site if you do not feel the need to compile them yourself. In fact the pkg_add command can even be given a URL to the package file instead of a local file.
The ports tree is maintained through CVS. You should occasionally use CVS to update your ports tree and the /usr/ports/infrastructure/build/out-of-date command to determine which of your installed ports needs to be upgraded to a newer version. I have written a shell script to automate this process. It is available at http://www.sanitarium.net/unix_stuff/wn.txt
If you don't know exactly what you are looking for in ports it is possible to search the entire tree with the make search command (run it in /usr/ports).
It is also possible to create your own ports of programs that aren't already in the ports system. There is documentation on the OpenBSD web site on how to do this.
Note: If you want the GNU tools to take precedence over the OpenBSD versions you will want to put /usr/local/bin at the beginning of your path and make symlinks to the standard filename. I have written a shell script to automate this process and made it available at http://www.sanitarium.net/unix_stuff/make_gnu_symlinks.csh.txt
OpenBSD patches are published at http://www.openbsd.org/errata.html. They are simple text patches. You must install the source code tarball from the last CD (src.tar.gz) into /usr/src before you can use them.
When you download one of these patches the installation procedure will be:
cd /usr/src patch -p0 < /path/to/patchfileThe patch comments will then tell you how to compile and install the patch. Note that if you are installing an older version of OpenBSD there may be more than one patch available that requires a kernel recompile. If this is the case you can install all of the patches and only recompile once.
The OpenBSD install program is very basic and completely text based. This may look ugly but it is very efficient. Once you know how to do it you can do a full install of OpenBSD in only a few minutes. In fact here is a video of someone both installing and configuring an OpenBSD system in less than 5 minutes: http://www.youtube.com/watch?v=N0cPFRdT7mQ
OpenBSD can be installed via CD, NFS, FTP, or HTTP. In fact you can download and write a single floppy disk from the OpenBSD site then download the rest during the actual install.
Here is a capture of me installing OpenBSD 3.6 on an old SPARCStation 5 system:
SPARCstation 5, No Keyboard ROM Rev. 2.15, 32 MB memory installed, Serial #7474505. Ethernet address 8:0:20:72:d:49, Host ID: 80720d49. Type help for more information ok boot cdrom 3.6/sparc/bsd.rd Boot device: iommu/sbus/espdma@5,8400000/esp@5,8800000/sd@6,0:d File and args >> OpenBSD BOOT 2.2 Booting 3.6sparc/bsd.rd @ 0x4000 3406660... console is ttya Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2004 OpenBSD. All rights reserved. http:/www.OpenBSD.org OpenBSD 3.6 (RAMDISK) #104: Fri Sep 17 16:07:51 MDT 2004 deraadt@sparc.openbsd.org:usr/src/sys/arch/sparc/compile/RAMDISK ...[lots of dmesg type stuff]... (I)nstall, (U)pgrade or (S)hell? i Welcome to the OpenBSDsparc 3.6 install program. ... Terminal type? [sun] vt102 IS YOUR DATA BACKED UP? As with anything that modifies disk contents, this program can cause SIGNIFICANT data loss. Proceed with install? [no] yes Cool! Let's get to it... You will now initialize the disk(s) that OpenBSD will use. To enable all available security features you should configure the disk(s) to allow the creation of separate filesystems for , /tmp, /var, /usr, and /home. Available disks are: sd0. Which one is the root disk? (or 'done') [sd0] sd0 This platform requires that partition offsetssizes be on cylinder boundaries. Partition offsetssizes will be rounded to the nearest cylinder automatically. Initial label editor (enter '?' for help at any prompt) > p device: dev/rsd0c ... 16 partitions: # size offset fstype [fsize bsize cpg] c: 35867280 0 unused 0 0 > a a offset: [0] size: [35867280] 64m Rounding to nearest cylinder: 132312 FS type: [4.2BSD] mount point: [none] / > p ... 16 partitions: # size offset fstype [fsize bsize cpg] a: 132312 0 4.2BSD 1024 8192 16 # c: 35867280 0 unused 0 0 > a b offset: [132312] size: [35734968] 2048m Rounding to nearest cylinder: 4194648 FS type: [swap] > a d offset: [4326960] size: [31540320] 2048m Rounding to nearest cylinder: 4194648 FS type: [4.2BSD] mount point: [none] /var > a e offset: [8521608] size: [27345672] FS type: [4.2BSD] mount point: [none] /usr > p ... 16 partitions: # size offset fstype [fsize bsize cpg] a: 132312 0 4.2BSD 1024 8192 16 # b: 4194648 132312 swap c: 35867280 0 unused 0 0 d: 4194648 4326960 4.2BSD 2048 16384 16 # var e: 27345672 8521608 4.2BSD 2048 16384 16 # usr > w > q No label changes. Mount point for sd0d (size=2097324k)? (or 'none' or 'done') [var] Mount point for sd0e (size=13672836k)? (or 'none' or 'done') [usr] Mount point for sd0d (size=2097324k)? (or 'none' or 'done') [var] done No more disks to initialize. OpenBSD filesystems: sd0a sd0d var sd0e usr The next step *DESTROYS* all existing data on these partitions! Are you really sure that you're ready to proceed? [no] yes dev/rsd0a: 132312 sectors in 37 cylinders of 12 tracks, 298 sectors 64.6MB in 1 cyl groups (40 cg, 69.84MB/g, 8832 i/g) dev/rsd0d: 4194648 sectors in 4692 cylinders of 3 tracks, 298 sectors 2048.2MB in 14 cyl groups (352 cg, 153.66MB/g, 19712 i/g) dev/rsd0e: 27345672 sectors in 30588 cylinders of 3 tracks, 298 sectors 13352.4MB in 87 cyl groups (352 cg, 153.66MB/g, 19712 i/g) dev/sd0a on /mnt type ffs (rw, asynchronous, local, ctime=Tue Nov 2 20:26:17 dev/sd0e on /mnt/usr type ffs (rw, asynchronous, local, nodev, ctime=Tue Nov dev/sd0d on /mnt/var type ffs (rw, asynchronous, local, nodev, nosuid, ctime=T System hostname? (short form, e.g. 'foo') rvsn2 Configure the network? [yes] Available interfaces are: le0. Which one do you wish to initialize? (or 'done') [le0] Symbolic (host) name for le0? [rvsn2] The media options for le0 are currently media: Ethernet autoselect (10baseT) Do you want to change the media options? [no] IPv4 address for le0? (or 'none' or 'dhcp') 192.168.100.3 Netmask? [255.255.255.0] No more interfaces to initialize. DNS domain name? (e.g. 'bar.com') [my.domain] sanitarium.net DNS nameserver? (IP address or 'none') [none] 192.168.100.202 Use the nameserver now? [yes] Default IPv4 route? (IPv4 address, 'dhcp' or 'none') 192.168.100.1 add net default: gateway 192.168.100.1 Edit hosts with ed? [no] Do you want to do any manual network configuration? [no] Password for root account? (will not echo) Password for root account? (again) You will now specify the location and names of the install sets you want to load. You will be able to repeat this step until all of your sets have been successfully loaded. If you are not sure what sets to install, refer to the installation notes for details on the contents of each. Sets can be located on a (m)ounted filesystem; a (c)drom, (d)isk or (t)ape device; or a (f)tp, (n)fs or (h)ttp server. Where are the install sets? (or 'done') c Available CD-ROMs are: cd0. Which one contains the install media? (or 'done') [cd0] Pathname to the sets? (or 'done') [3.6/sparc] The following sets are available. Enter a filename, 'all' to select all the sets, or 'done'. You may de-select a set by prepending a '-' to its name. [X] bsd [X] bsd.rd [X] base36.tgz [X] etc36.tgz [X] misc36.tgz [X] comp36.tgz [X] man36.tgz [X] game36.tgz [ ] xbase36.tgz [ ] xetc36.tgz [ ] xshare36.tgz [ ] xfont36.tgz [ ] xserv36.tgz File name? (or 'done') [xbase36.tgz] * ... File name? (or 'done') [done] -bsd.* The following sets are available. Enter a filename, 'all' to select all the sets, or 'done'. You may de-select a set by prepending a '-' to its name. [X] bsd [ ] bsd.rd [X] base36.tgz [X] etc36.tgz [X] misc36.tgz [X] comp36.tgz [X] man36.tgz [X] game36.tgz [X] xbase36.tgz [X] xetc36.tgz [X] xshare36.tgz [X] xfont36.tgz [X] xserv36.tgz File name? (or 'done') [bsd.rd] done Ready to install sets? [yes] Installing... Sets can be located on a (m)ounted filesystem; a (c)drom, (d)isk or (t)ape device; or a (f)tp, (n)fs or (h)ttp server. Where are the install sets? (or 'done') done Start sshd(8) by default? [yes] yes Saving configuration files...done. Generating initial host.random file...done. What timezone are you in? ('?' for list) [CanadaMountain] EST5EDT Setting local timezone to 'EST5EDT'...done. Making all device nodes...done. Installing boot block... boot: mnt/boot proto: mnt/usr/mdec/bootxx device: dev/rsd0c architecture: sun4c mnt/usr/mdec/bootxx: entry point 0x340000 mnt/usr/mdec/bootxx: a.out header left on proto bootblock size 7680 room for 256 filesystem blocks at 0x3417b8 mnt/boot: block numbers: 53472 53504 53536 9308 CONGRATULATIONS! Your OpenBSD install has been successfully completed! To boot the new system, enter halt at the command prompt. Once the system has halted, reset the machine and boot from the disk. # reboot syncing disks... done rebooting Resetting ... SPARCstation 5, No Keyboard ROM Rev. 2.15, 32 MB memory installed, Serial #7474505. Ethernet address 8:0:20:72:d:49, Host ID: 80720d49. Boot device: iommu/sbus/espdma@5,8400000/esp@5,8800000/sd@3,0 File and args: >> OpenBSD BOOT 2.2 Booting bsd @ 0x4000 ... Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2004 OpenBSD. All rights reserved. http:/www.OpenBSD.org OpenBSD 3.6 (GENERIC) #203: Fri Sep 17 15:18:56 MDT 2004 deraadt@sparc.openbsd.org:usr/src/sys/arch/sparc/compile/GENERIC ...[lots of dmesg type stuff]... OpenBSDsparc (rvsn2.sanitarium.net) (console) login: root Password: Nov 2 15:51:57 rvsn2 login: ROOT LOGIN (root) ON console OpenBSD 3.6 (GENERIC) #203: Fri Sep 17 15:18:56 MDT 2004 Welcome to OpenBSD: The proactively secure Unix-like operating system. Terminal type? [sun] vt102 Don't login as root, use su Read the afterboot(8) man page for administration advice. rvsn2#