8 Printer setup
8.3 magicfilter
magicfilter is a customisable and extendable printer filter. It examines the provided input files to determine what their format is, and handles them appropriately. magicfilter is intended to be used as an input filter for LPD – configured as “if” in printcap. Because the input filter parameter for printcap cannot be given with arguments, a separate script is used for each printer.
By convention, the scripts for magicfilter are in the directory /etc/magicfilter, and are named after the printer. printcap entries may look like this – pencil|lp|PostScript|ljet4|HP LaserJet 4:\ :lp=/dev/lp1:sd=/var/spool/lpd/pencil:sh:mx#0:\ :if=/usr/sbin/printers/ljet4: crayon|dj550c|color|HP DeskJet 550C:\ :lp=/dev/lp2:sd=/var/spool/lpd/crayon:sh:mx#0:\ :if=/usr/sbin/printers/dj550c:
Depending on the version and configuration of your installation of magicfilter,
/usr/sbin/printers may be /etc/magicfilter or some other location. A magicfilter printcap entry may look something like this too lp|hplj4l|HP Laserjet 4L:\ :lp=/dev/lp1:sd=/var/spool/lpd/hplj4l:\ :sh:pw#80:pl#72:px#1440:mx#0:\ :if=/etc/magicfilter/ljet4l-filter:\ :af=/var/log/lp-acct:lf=/var/log/lp-errs:
Whatever their location, the actual script files are interpreted by the magicfilter program, as shown by the “#!” at the top of the file. #!/usr/sbin/magicfilter Quiz questions 1. What must appear in /etc/printcap for a postscript printer connected at /dev/lp0? 2. In what format are files which are submitted to lpr? 3. What does apsfilter do? 4. What does magicfilter do? 5. How does one print to a windows printer from the command line? 6. What is /etc/magicfilter, and what would you expect to find there? Assignments 1. If you are running LPRng or CUPS, install the original BSD printing system, and set up your printer using either apsfilter or magicfilter.
Answers to quiz questions
1. If the printer is named hplj, then something like hplj:lp=/dev/lp0:sd=/var/spool/hplj:
2. Usually postscript, but other formats may be converted to postscript. 3. apsfilter converts various input formats to the printer's native format.
4. magicfilter is a script language to convert various input formats to a printer's native format. 5. cat rawprintdata | smbclient //server/hplj bigsecret U guest P
6. It's the conventional configuration directory for magicfilter, and contains a magicfilter script for each printer that requires one.
9 Documentation LPI 102 Course Notes 55
9 Documentation
Arnold's Laws of Documentation: (1) If it should exist, it doesn't. (2) If it does exist, it's out of date. (3) Only documentation for useless programs transcends the first two laws. – /usr/share/games/fortune/definitionsLPIC topic 1.108.1 — Use and manage local system documentation [4]
Weight: 4 Objective Candidates should be able to use and administer man and the material in /usr/share/doc/. This objective includes finding relevant man pages, searching man page sections, finding commands and man pages related to them, and configuring access to man sources and the man system. It also includes using system documentation stored in /usr/share/doc/ and determining what documentation to keep in /usr/share/doc/. Key files, terms, and utilities include man system manual pages apropos search for manual page keywords whatis show available man pages and their titles MANPATH path for man pages9.1 man pages
For most commands that you can type on a Linux system there is a man page. Man pages are useful if you need detailed information about a command. A man page is an electronic document with a number of sections: • NAME – the name of the command, and a very short description • SYNOPSIS – command line usage • DESCRIPTION – all about the command • OPTIONS – detailed information about each option the command accepts • FILES – which files are relevant to this program • SEE ALSO – other sources of information, including other man pages • BUGS – things that byte • AUTHOR – who was responsible for the man page, or alternatively, for the program In practice, few man pages have all these sections.The syntax for man is one of these.
man [section] pagename
If you don't specify the section number, then the first man page found is used. Here are some examples of using man:
$ man man $ man cd
$ man ls $ man passwd $ man 1 passwd $ man 5 passwd MANPATH
man searches the subdirectories of the directories listed in the MANPATH environment variables.
foo:~ # echo $MANPATH
/usr/share/man:/usr/local/man:/usr/X11R6/man:/usr/man:/usr/openwin/m an
foo:~ # ls /usr/share/man/
. de es it man1 man3 man5 man7 man9 pt_BR .. de_DE fr_FR ja man2 man4 man6 man8 mann
stop:~ # ls -C /usr/share/man/man1 | head -5
. ldappasswd.1.gz perlvar.1.gz .. ldapsearch.1.gz perlvmesa.1.gz a2p.1.gz ldd.1.gz perlvms.1.gz addftinfo.1.gz less.1.gz perlvos.1.gz addr2line.1.gz lesskey.1.gz perlwin32.1.gz
If you have man pages in other locations, you can modify the value of MANPATH in
/etc/profile (or a related script). Of course, it's not quite so simple. The contents of MANPATH is usually set to the output of the command manpath.
manpath is configured by the file /etc/manpath.config
foo:~ $ manpath
manpath: warning: $MANPATH set, ignoring /etc/manpath.config /usr/local/man:/usr/share/man:/usr/X11R6/man:/opt/gnome/man
So the configuration for man is actually contained in one of these files (depending on the version of man) – but the simplest way to change things is to modify the MANPATH environment variable in the user's profile.
• /etc/manpath.config (version 2.x) • /etc/man.config (version 1.x)
foo:~ $ ls /etc/man*
whatis
When a name of a man page is used in a number of sections, whatis lists the man pages available. The database used by whatis which contains the contents of all the “NAME” sections of manual pages is updated by makewhatis.
foo:~ # whatis
whatis what?
foo:~ # whatis whatis
whatis (1) - display manual page descriptions foo:~ # whatis passwd
passwd (1ssl) - compute password hashes passwd (1) - change user password passwd (5) - The password file reception:~ # man 1ssl passwd
9 Documentation LPI 102 Course Notes 57
Reformatting passwd(1ssl), please wait... foo:~ # man 1 passwd
Reformatting passwd(1), please wait... foo:~ # man 5 passwd
Reformatting passwd(5), please wait... foo:~ # whatis thematrix
thematrix: nothing appropriate. apropos
You can search the “NAME” sections of man pages for text of your choice using apropos.
apropos searches for text in a similar way to grep i pattern (case insensitive, word boundaries don't matter).
foo:~ $ apropos
apropos what?
foo:~ $ apropos apropos
apropos (1) - search the manual page names and descriptions foo:~ $ apropos printer
foo:~ $ apropos profile
foo:~ $ apropos passwd
foo:~ $ apropos cd
foo:~ $ apropos motd
foo:~ $ man -k motd
foo:~ $ apropos .
When you are searching for specific documentation, it can be quite useful to filter the output of apropos through grep to clarify what you meant.
foo:~ $ apropos cd | grep -w cd
foo:~ $ apropos scanner | grep -i USB
9.2 /usr/share/doc
This directory is contains all manner of documentation for your system, including:
• Package documentation – each installed package installs its documentation in its own directory, either under /usr/share/doc or under /usr/share/doc/packages (SuSE). Generally distributions package the original README, ChangeLog and COPYING files, and quite often the “contrib” directory (scripts and extensions which can be useful with a given program).
• HOWTOs – how to do various things – /usr/share/doc/howto – but not always installed. • FAQs – frequently asked questions can also appear, but these are generally not the ones you
want.
• Books – when you install the NAG (network administrator guide) and SAG (System Administration Guide) and other books from the Linux Documentation Project, they may be installed at /usr/share/doc/books.
Here is what /usr/share/doc looks like on a SuSE system.
fred@suse:~> ls /usr/share/doc
RELEASE_NOTES.de.html howto selfhtml susetour RELEASE_NOTES.en.html packages support-db vnc-3.3.3r2 RELEASE_NOTES.hu.html sdb susehilf
3ddiag kdebase3 samba
DirectFB kdegames3 samba-vscan ImageMagick kdegraphics3 sane
MPlayer kdegraphics3-scan sash NVIDIA_GLX kdelibs3 sax
fred@suse:~ $ less /usr/share/doc/packages/*/README On a Debian system, we see documentation for each installed package –
fred@debian:~$ ls -C /usr/share/doc | head -5
adduser info makedev syslinux apt ipchains man-db sysvinit apt-utils iptables manpages tar at klogd mawk tasksel base-config lbxproxy mbr tcpd fred@debian:~ $ less /usr/share/doc/*/README
/usr/share/doc on RedHat systems looks quite similar, but contains the version number of each package.
desktop@redhat:~ $ ls -C /usr/share/doc/ | head -5 4Suite-0.11.1 libgnomeui-2.0.3 GConf-1.0.9 libgtop2-2.0.0 GConf2-1.2.1 libjpeg-6b
HTML libmrproject-0.6 ImageMagick-5.4.7 libogg-1.0
desktop@redhat:~ $ less /usr/share/doc/*/README
9.3 Review
Quiz questions
1. What type of documentation is found in /usr/share/doc? 2. What is the difference between apropos and whatis? 3. What is MANPATH, and what is its function?
4. How and why would a system administrator make changes to MANPATH?
Assignments
1. Read the man pages for man, apropos and whatis. Which of these refer to MANPATH? 2. Find and read the documentation on the fileutils project. How recent are the changes
included in your installation, and what were they? Are there any outstanding problems with fileutils? How many contributors are there to the fileutils project?
3. Read all the documentation in /usr/share/doc :), or alternatively find the Coffee HOWTO, and make notes on its contents.
4. Run the command info info, and then browse the info pages using the command info.
Answers to quiz questions
1. The documentation for installed software that is not part of the man page system.
9 Documentation LPI 102 Course Notes 59
keywords.
3. MANPATH is an environment variable which specifies where to search for man pages. 4. The administrator would make changes to include man pages stored in nondefault