Thursday 10 November 2011

The FreeBSD experience - part 2 post-installation basics

In Part 1 I described how to get a working installation in a VM. In this part I will go through the steps to get some tools on the box to make our lives a bit easier.

I'm going to install :

  • bash shell
  • portmaster
  • portupgrade
  • portmanager
  • midnight commander
  • nano (although I can find my way in vi)
  • sudo
  • links (a text-based browser always comes in handy)



First things first: fix su for SSH access
Normally an openSSH installation does not accept a root-login for security reasons but my normal user account can't do anything without extra privileges so we're going to add marcel to the group wheel.

$ su
su : Sorry
Nov  9 19:46:37 beesd su: BAD SU marcel to root on /dev/ttyv0
$
Login as root and add the user to the group wheel

beesd# pw user mod marcel -G wheel
You can check if the user is added to the right groups with the following command:
groups marcel

Since the machine gets its IP address via DHCP check (ifconfig) the current IP address for connecting with SSH. Now let's try:

marcel@tuxtop:~$ ssh 192.168.1.119
The authenticity of host '192.168.1.119 (192.168.1.119)' can't be established.
RSA key fingerprint is 3a:80:ee:75:81:5d:45:55:f2:43:fc:1e:75:f2:56:2c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.119' (RSA) to the list of known hosts.
Password:
Last login: Wed Nov  9 19:35:54 2011
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
    The Regents of the University of California.  All rights reserved.

FreeBSD 8.2-RELEASE (GENERIC) #0: Thu Feb 17 02:41:51 UTC 2011

Welcome to FreeBSD!

[...]

$ su
Password:
beesd#
Cheers !


Change the IP-address to a static address
In /etc/rc.conf find:
ifconfig_em0="DHCP"
Change this to:
ifconfig_em0="inet 192.168.1.22 netmask 255.255.255.0"
add:
defaultrouter="192.168.1.1"
Restart the network:
# /etc/rc.d/netif restart
Portsnap

Portsnap is a prerequisite to get applications installed. There are also other options like CVSup or installing via sysinstall but I'm goin to use portsnap.
FreeBSD installs applications (ports) from source. Although there are Linux-like repositories with binary packages, it is prefered to build them from source. Luckily the ports-mechanism works really easy and does not required deep knowledge of compilers, dependencies, etc.. 

From the FreeBSD site:
Portsnap is a system for securely distributing the FreeBSD ports tree. Approximately once an hour, a “snapshot” of the ports tree is generated, repackaged, and cryptographically signed. The resulting files are then distributed via HTTP.
Like CVSup, Portsnap uses a pull model of updating: The packaged and signed ports trees are placed on a web server which waits passively for clients to request files. Users must either run portsnap(8) manually to download updates or set up a cron(8) job to download updates automatically on a regular basis.
For technical reasons, Portsnap does not update the “live” ports tree in /usr/ports/ directly; instead, it works via a compressed copy of the ports tree stored in /var/db/portsnap/ by default. This compressed copy is then used to update the live ports tree.
With these two commands we download and extract the compressed snapshot of the ports tree.
# portsnap fetch
# portsnap extract
To update the ports-tree:
# portsnap update
Application installation
We're ready now to add the first applications to the system. First we're going to replace the C-shell with the Bash-shell.

beesd# whereis bash
bash: /usr/ports/shells/bash
beesd# cd /usr/ports/shells/bash
beesd# make install clean
Main steps: find the location of the port with whereis, change directory and use make install clean to compile and install the port. More info on Port installation is in the FreeBSD site.

Often you will be ask which options to enable or install during compilation. Read this thread for more info on "silent installs".

After installation change the default to bash
beesd# chsh -s /usr/local/bin/bash root
chsh: user information updated
beesd# chsh -s /usr/local/bin/bash marcel
chsh: user information updated
Portmaster and portmanager are tools which are used primarily to upgrade installed ports

Now let's repeat the installation steps for portmaster:

# whereis portmaster
portmaster: /usr/ports/ports-mgmt/portmaster
# cd /usr/ports/ports-mgmt/portmaster
# make install clean
Installation of portmanager with portmaster:
# whereis portmanager
portmanager: /usr/ports/ports-mgmt/portmanager
# portmaster ports-mgmt/portmanager
Now rinse and repeat this with your favourite tool to install the rest of the ports.

No comments:

Post a Comment