in Free BSD using packages & ports
FreeBSD provides two complementary technologies for installing third-party software on your system: the FreeBSD Ports Collection (for installing from source), and packages (for installing from pre-built binaries). Either method may be used to install the newest version of your favorite applications from local media or straight off the network. By installing from the port, you can
tweak the compilation options to (for example) generate code that is specific to a Pentium 4 or Athlon processor.By building from the port you do not have to accept the default options, and can set them yourself.
Finding Your Application :–
Before you can install any applications you need to know what you want, and what the application is called.
The FreeBSD web site maintains an up-to-date searchable list of all the available applications, at
http://www.FreeBSD.org/ports/. The ports are divided into categories, and you may either search for an application by name (if you know it), or see all the applications available in a category.
If you know the exact name of the port, but just need to find out which category it is in, you can use the whereis command. Simply type whereis file, where file is the program you want to install. If it is found on your system, you will be told where it is, as follows:
# whereis lsof
This tells us that lsof (a system utility) can be found in the /usr/ports/sysutils/lsof directory.
Yet another way to find a particular port is by using the Ports Collection’s built-in search mechanism. To use the search feature, you will need to be in the /usr/ports directory. Once in that directory, run make search name=program-name where program-name is the name of the program you want to find. For example, if you were looking for lsof:
# cd /usr/ports
# make search
information about open files (similar to fstat(1))
Installing a Package
You can use the pkg_add utility to install a FreeBSD software package from a local file or from a server on the network.
# ftp -a
Connected to ftp2.FreeBSD.org.
ftp2.FreeBSD.org FTP server (Version 6.00LS) ready.
331 Guest login
ok, send your email address as password.
machine is in Vienna, VA, USA, hosted by Verio.
Questions? E-mail email@example.com.
230 Guest login
ok, access restrictions apply.
type is UNIX.
Using binary mode
to transfer files.
250 CWD command
lsof-4.56.4.tgz remote: lsof-4.56.4.tgz
200 PORT command
BINARY mode data connection for ‘lsof-4.56.4.tgz’ (92375 bytes).
received in 5.60 seconds (16.11 KB/s)
If you do not have a source of local packages (such as a FreeBSD CD-ROM set) then it will probably be easier to use the -r option to pkg_add.
# pkg_add -r lsof
# pkg_info lsof
# pkg_version lsof
# pkg_delete lsof
All package information is stored within the /var/db/pkg directory. The installed file list and descriptions of each package can be found within files in this directory.
5. Using the Ports Collection
Before you can install ports, you must first obtain the Ports Collection–which is essentially a set of
Makefiles, patches, and description files placed in /usr/ports. Make sure /usr/ports is empty before
you run CVSup for the first time! If you already have the Ports Collection present, obtained from another source, CVSup will not prune removed patch files.
1. Install the net/cvsup-without-gui package:
# pkg_add -r cvsup-without-gui
2. Run cvsup:
# cvsup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile
Alternate method:- Portsnap Method
# pkg_add -r portsnap
# mkdir /usr/ports
# portsnap fetch
# portsnap extract
# portsnap update
To begin, change to the directory for the port you want to install:
# cd /usr/ports/sysutils/lsof
once inside the lsof directory, you will see the port skeleton. The next step is to compile, or “build”,
the port. This is done by simply typing make at the prompt. Once you have done so, you should see something like this:
>> lsof_4.57D.freebsd.tar.gz doesn’t seem to exist in
>> Attempting to fetch from ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/.
===> Extracting for lsof-4.57
>> Checksum OK for lsof_4.57D.freebsd.tar.gz.
===> Patching for lsof-4.57
===> Applying FreeBSD patches for lsof-4.57
===> Configuring for lsof-4.57
===> Building for lsof-4.57
Notice that once the compile is complete you are returned to your prompt. The next step is to install
the port. In order to install it, you simply need to tack one word onto the make command, and that word is install:
# make install
===> Installing for lsof-4.57
===> Generating temporary packing list
===>Compressing manual pages for lsof-4.57
===>Registering installation for lsof-4.57
This porthas installed the following binaries which execute with increased privileges.
#It is a good idea to delete the working subdirectory, which contains all the temporary files used during compilation. Not only does it consume valuable disk space, but it would also cause problems later when upgrading to the newer version of the port.
# make clean
===> Cleaning for lsof-4.57
Note: You can save two extra steps by just running make install clean instead of make, make install and make clean as three separate steps.
Iii) Upgrading Ports
Once you have updated your Ports Collection, before attempting a port upgrade, you should check
/usr/ports/UPDATING. This file describes various issues and additional steps users may encounter and need to perform when updating a port.
# cd /usr/ports/ports-mgmt/portupgrade
# make install clean
# portupgrade -ai
# portupgrade -R firefox
To free the disk space consumed while installing packages
# portsclean -C