1.) Edit /etc/make.conf [Top]
During the workshop you will be using the
make command to install software via the FreeBSD ports system. We must override a default setting on your system so that FreeBSD will attempt to fetch the source for the port from a local server and not from the default remote site of ftp.freebsd.org.
We can specifiy this by editing the file /etc/make.conf and adding a single line (don't break the line) that
make to look on a local server first. Use vi or ee to edit the /etc/make.conf file.
First, edit /etc/make.conf (you must be root to do this):
Scroll down to the last line of the file, press the "o" (lower-case oh) key to insert a line below the last line, and then type in the following:
$ su -
# vi /etc/make.conf
MASTER_SITE_OVERRIDE=ftp://noc/pub/FreeBSD/ports/distfiles/To save and exit you must press:
:wq <ENTER>For this class our local DNS (22.214.171.124 or noc.eu.cctld.org) and FreeBSD 6.2 will do domain completion for you, thus we can get away with only using "noc".
2.) Use ports to install the Joe editor [Top]
For this exercise you need to logged in as root in a terminal (
Let's install the Joe editor version 3.x. This is an alternative to using the vi and ee editors, which you can use if you wish.
First do the following:
On the first page of output you should see something like this:
# cd /usr/ports
# make search name=joe | more
From this you can see that the Joe editor resides in /usr/ports/editors/joe. So, to install Joe version 3.5.1 you do the following:
Port: joe-3.5.1 Path: /usr/ports/editors/joe Info: Joe's Own Editor Maint: firstname.lastname@example.org B-deps: aspell-0.60.4_4 gettext-0.14.5_2 gmake-3.81_1 libiconv-1.9.2_2 R-deps: aspell-0.60.4_4 gettext-0.14.5_2 libiconv-1.9.2_2 WWW: http://sourceforge.net/projects/joe-editor/
Make will download the joe editor source (hopefully from our local server!), and then compile the source. Note, if you are missing any of the items listed on the "deps" lines, then these may be downloaded and compiled as well.
# cd /usr/ports/editors/joe
# make install
"Make install" will place the compiled binary files in the appropriate directories on your system and update the appropriate configuration files if necessary. You can issue the single command "
make install" instead.
You can now type:
For more information.
# rehash (to re-read items in your directory path)
# man joe
If you wish to deinstall a port once it is installed, for instance joe, you would do the following (please don't do this):
And, if you decided that was a mistake, you can now do the following to reinstall a port (after it's been installed once):
# cd /usr/ports/editors/joe
# make deinstall
Also, note that the Joe port has been built and installed and will now appear as a package. You can type:
# cd /usr/ports/editors/joe
# make reinstall
You will see that the Joe port now appears as an installed package. Thus, you could manipulate this software with package commands (
# pkg_info joe\*
3.) Use the package system to add Apache version 2 with SSL support [Top]
For this exercise you need to be logged in as root.
Later in the week we may need this software to do our work. We will be installing:
If you want to learn more about apache type:
# pkg_add ftp://noc/pub/FreeBSD/6.2-RELEASE/i386/packages/All/apache-2.2.3.tbz
In our next exercise we will go over how to configure Apache version 2.2 to run at system startup. You may have noticed that as the software installs you are told how to do this as well...
# man httpd
4.) Edit /etc/rc.conf to enable Apache [Top]
For this exercise you need to be loggedin as root in a terminal.
Remember where third party software installs configuration and startup scripts?
Yes? Let's go read what the Apache 2.2 startup script says about getting the service to run at system start time.
You should notice that there is now an apache22 directory. But, first let's look and see if there is an Apache startup script installed in /usr/local/etc/rc.d.
# cd /usr/local/etc
You should see the file apache22. Either edit this file (vi, ee, joe filename), or display the file's contents to the screen (more, less), and read what it says.
# cd rc.d
The comment that says:
So, this means you need to add a line to /etc/rc.conf that reads:# Add the following lines to the /etc/rc.conf to enable apache22: # apache22_enable (bool): Set to "NO" by default. # Set it to "YES" to enable apache22 # # etc...
You can place this line at the bottom of the file. For instance, to do this using the newly installed Joe editor you could type:
Add in the line, save the file, and quit (ctrl-k-x)
# joe /etc/rc.conf
Now, you can start the Apache web server. You should be in the directory /usr/local/etc/rc.d/. So, to start the server you simply type:
In addition, you can type:
# ./apache22 start
To see all the various options available to you.
The server now started because you placed the entry, 'apache22_enable="YES"' in /etc/rc.conf. If that is not in place, then even if you run the Apache startup script correctly, the service itself will not start.
From this point on, when you reboot your machine the Apache web server will automatically start.
To verify that it is working for you you can type:
And you should see the initial Apache web page for FreeBSD that says, "It works!". Type "q" to exit this text-based web browser.
# links 127.0.0.1
5.) Mount a USB stick on your machine [Top]
For this exercise please use your admin user account. Note that the prompt will be shown as "$" to indicate commands to be done as a normal user. We will use the
sudo facility to allow your user to issue privileged commands.
We've mentioned that USB sticks show up as a SCSI device and they are created dynamically when plugged in to your machine. We'll try mounting one on your machine now. If you do not have access to a USB stick, then watch as your instructor does this on the main screen in the classroom as well.
To mount a USB stick's file system under FreeBSD here is, more or less, what you do:
Open two terminal windows on your machine and you should be logged in as "admin" not root. In one terminal type:
When prompted for a password enter in your account's password.
# sudo tail -f /var/log/messages
Now plug-in your USB stick in an available USB slot on your machine.
In the open window where the
tail command is running you should see some descriptive message come up about your USB stick. From this you should be able to tell what device node FreeBSD has assigned for your device. Very likely the device will be da0. Thus, the first slice on your USB stick will be da0s1. You can check for this by doing:
If your device appeared as some other device than da0 and you need help ask your instructor or an assistant to have a look.
$ ls /dev/da*
Now let's create a place in your file system where you can mount your USB stick's files. By convention we can use "/media". Under "/media" we will create the "/media/usb" directory and mount our USB stick. To do this do:
Now to see that the disk is mounted type:
$ sudo mkdir /media/usb
$ sudo mount -t msdosfs /dev/da0s1 /media/usb
Have a look at your files to verify that things are as you expected and then unmount your USB stick from the file system. Note, if you do
$ df -h
cd /media/usbyou must leave this directory before unmounting the device.
And, prove to yourself that the disk is really unmounted:
$ ls /media/usb
$ sudo umount /media/usb
If you have questions about any of this please speak up.
$ df -h
6.) Multi to Single to Multi -user mode [Top]
For this exercise you'll need to be root (or, you can use the
We are going to drop down to single-user mode. This will stop your Gnome Desktop session and leave you in a /bin/sh shell as the user root.
To do this press CTRL-ALT-F1 to open one of your virtual consoles.
If you see a login: prompt, then log in as root. Not necessary if you rae already logged in as root.
When prompted with:
# init 1
Just press ENTER.
Enter full pathname of shell or RETURN for /bin/sh:
Now, different form Linux, to get back to multi-user mode you can type:
And, that's it! Pretty simple. Note, there is no run-level 5 (as in Linux), or run-level 3 (often network, multi-user without GUI in Linux). In addition, we have not set your machines to default to a graphical login. To get back to your Gnome Desktop you will need to log back in as root, and the type:
to start the Gnome Display Manager (gdm) once again. Once you have done this, then you can log in to your Gnome Desktop as the "admin" user once again.