FreeBSD : Hints for Newbies


Using the "man" command, the online manual

To get online help when logged in to your unix shell account, you type in the 'man' command. The first man command would be 'man man'; this brings up the manual page for the 'man' command itself. Unfortunately, the 'man' page for 'man' doesn't tell you something you need to know to be able to fully use the 'man' command: how to access the numbered man pages under the heading "SEE ALSO". For example, the following is the output from typing in 'man cron':

CRON(8)                 FreeBSD System Manager's Manual                CRON(8)
 
NAME
     cron - daemon to execute scheduled commands (Vixie Cron)
 
SYNOPSIS
     cron [-x debugflag[,...]]
 
DESCRIPTION
     Cron should be started from /etc/rc or /etc/rc.local. It will return im-
     mediately, so you don't need to start it with '&'.
 
     Cron searches /var/cron/tabs for crontab files which are named after ac-
     counts in /etc/passwd; crontabs found are loaded into memory.  Cron also
     searches for /etc/crontab which is in a different format (see
     crontab(5)).  Cron then wakes up every minute, examining all stored
     crontabs, checking each command to see if it should be run in the current
     minute.  When executing commands, any output is mailed to the owner of
     the crontab (or to the user named in the MAILTO environment variable in
     the crontab, if such exists).
 
     Additionally, cron checks each minute to see if its spool directory's
     modtime (or the modtime on /etc/crontab) has changed, and if it has, cron
     will then examine the modtime on all crontabs and reload those which have
     changed.  Thus cron need not be restarted whenever a crontab file is mod-
     ified.  Note that the crontab(1) command updates the modtime of the spool
     directory whenever it changes a crontab.
 
SEE ALSO
     crontab(1),  crontab(5)
 
AUTHORS
     Paul Vixie 
 
BSD                            December 20, 1993                             1

Under 'SEE ALSO' are 'crontab(1) and crontab(5). The syntax for viewing 'crontab(5)' would be 'man 5 crontab'. This syntax is not readily apparent, and in versions of shipped with FreeBSD 3.4 and earlier, is not covered in the 'man' page for 'man' itself!

NOTE: This was corrected in later man editions


Choosing Your Default Editor

When I first tried to set up a crontab (a special file that runs programs for you according to a schedule which you set up) using the command 'crontab -e' (which uses the default editor), I found myself in the 'vi' editor, definitely not a user-friendly program 1. There are no menus, and I had to guess at what to do, as I didn't know how to get out of the progam. I tried control-c, which only gave a mysterious 'interrupt' response, and then control-z, which was helpful, as it suspended execution and returned me to the shell prompt. I then had to search using 'man vi' to try to find out both how to quit vi (press 'Esc' until your computer beeps and then press ':q') and 'man tcsh' or was it 'man csh' to find out how to get back into a suspended program (type "%%" and press enter [aka 'return'] for the current suspended job).

The easy solution is to use pico, a user-friendly, menu-driven simple text editor. To make this your default, you edit the initialization files that are read when you login. If your login shell is 'csh' or 'tcsh', the file to edit is called '.cshrc'. Type 'pico .cshrc' and edit the 'EDITOR' environment variable; change 'vi' to 'pico'. You should make the same change to '.login'. You can make this new default take effect immediately by the commands 'source .cshrc' and 'source .login' (it will also become the default when you logout and log back in). If you're using the Bourne or Korn shells or BASH, you change the EDITOR environment variable in '.profile' which is used by those shells.

On Using Crontab

Here is the listing, using the 'crontab -l' command, of one of my crontabs:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.Hztvs11699 installed on Thu Dec 16 16:24:23 1999)
# (Cron version -- $Id: crontab.c,v 1.6.2.3 1998/03/09 11:42:00 jkh Exp $)
MAILTO="johnpipe@nwserv.com"
PATH=/usr/bin:/bin:/usr/home/parvifox/bin
1 1 * * 1 sklogs

The MAILTO variable will allow the cron daemon to send email error notification to me on my personal account, which is on a different server than that on which the crontab is running. The PATH variable lets the cron program know where to find the program to run; in this case, it is 'sklogs', a shell script in /usr/home/parvifox/bin/. You can find the full details using 'man crontab' and accessing the different numbered pages listed under SEE ALSO.

Note that crontab expects each command or environment variable to be on a separate line; this means that, if you are using pico, you cannot write a command line longer than the maximum line length for pico. By using a script for the programming details, this problem is obviated. You could, of course, learn vi, which can write very long lines! This is actually a very good thing to do; vi is installed on just about every unix-type system in the world, and although a little hard for some of us to learn, is very fast once you get the hang of it. I used it in Feb 2K to update this page. Search for (it may even be installed on your system) "vi tutor" or tutor.vi on the www. Also, on Linux systems type "vimtutor".

I should also mention that on the freeBSD CD there is "ee" (easy edit), a more capable editor than pico that can handle longer lines.


1 here is part of the 'man' entry for vi:
FAST STARTUP
       This section will tell you the  minimum  amount  that  you
       need to do simple editing tasks using vi.  If you've never
       used any screen editor before, you're likely to have prob-
       lems even with this simple introduction.  In that case you
       should find someone that already knows vi  and  have  them
       walk you through this section.


X Windows

X Windows is a means of logging onto a unix system with a graphic interface. This can be done from Microsoft systems via tcp/ip with a 'X server' such as are available from tucows. These programs give you the ability to run GUI programs on your unix shell account, even over the internet. This means that, if you or your ISP have X aware clients (programs) installed on the shell machine, you can use those; bear in mind that X is slow over the 'net, and is bandwidth intensive. One isp account I use has Xemacs, for instance, a X-windows version that has a mouse-operable graphic user interface. On another, there were very few, but some programs, such as pine, can use their color options on the X terminal window. I've also noticed that even the non-X emacs is 'X' aware, and provides mouse-selectable menus. An X server uses an environment variable called DISPLAY to make a connection; .

In my case, as the ISP I had at the time used dynamic IP assignment, I got a simple script entry from them for my .login script file [for tcsh] which queried the dynamically assigned IP after login and assigned it to the variable DISPLAY ,which gets used by xterm to know where is the x terminal to connect to (if this variable is set, emacs will detect it and try to run as an X client unless the '-nw' command-line switch is used). A simple command, xwin, is implemented via a script in my $HOME/bin directory which starts the x connection with the x server on my PC.

Here's what the .login looked like:


	# $FreeBSD: src/share/skel/dot.login,v 1.11.2.1 1999/08/29 16:47:50 peter Exp $
	#
	# .login - csh login script, read by login shell, 
	#          after `.cshrc' at login.
	#
	# see also csh(1), environ(7).
	#

	set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/bin /usr/X11R6/bin $HOME/bin) 
	setenv MANPATH "/usr/share/man:/usr/X11R6/man:/usr/local/man"
	set ipaddress = `w -h -i -n $USER | head -1 | awk '{ print $3 }' | sed -e's/:.*$//g'`
	setenv DISPLAY ${ipaddress}:0

	# Interviews settings
	#setenv CPU "FREEBSD"
	#set path = ($path /usr/local/interviews/bin/$CPU)
	#setenv MANPATH "${MANPATH}:/usr/local/interviews/man"

	# A rightous umask
	umask 22

Here's the script 'xwin':

	xterm -fn 12x24 &

which gives a decently large font size which I can read without glasses. The "-fn [fontname] &" command options mean "use the font named '12x24' and run in the background". In the case of the X-server I used (Xwin32) the fonts are those which are stored on the PC in the server's font library folder. This script is executed from my login shell.


Firewall Hints

Created 17 December 1999
Revised 29 May 2002