Linux Package Installation and Printing

Posted: September 24, 2010 in Uncategorized
Generally, a large part of Linux consists of the packages you load on your system. These packages may be for various specific purposes such as adding shadow passwords, adding a secure telnet client, adding some type of network service, or perhaps upgrading the Apache web server. Whatever the reason, you will need to find the appropriate package on the web, download it, compile it, and install it. The package will come with instructions on how to do this. Some are easy to install, others may be complicated. This section gives general instructions commonly found and required when installing many packages. Please be aware, however, that there may be differences between these instructions and those that come with your package. You should read the instructions that come with your package.

Package installations

tar.gz source package general instructions

  1. Read the install documentation associated with the installation
  2. Put the packed file in the directory you want it to be installed under.
  3. Examine the package with the command “tar tvzpf <packagename>.tar.gz” to see where it will install.
  4. Unpack the tar.gz file in one step with “tar xvzpf <packagename>.tar.gz or in two steps with “gunzip <packagename>.tar.gz” and “tar xpf <packagename>.tar” It will create a directory like “packagename-2.3.4” and place the extracted information here.
  5. Typically the following outlines the rest of the steps but they will vary from package to package. Go into the created subdirectory and type “./configure”.
  6. Type “make all” or “./make”
  7. Type “make install” or “./make install”

Installing Redhat Packages

rpm -help To get help
rpm -q mypack-1.0.1.rpm Queries the database of installed packages to see if this package is installed or what version of it is installed.
rpm -ivh mypack-1.0-1.rpm Installs mypack.
rpm -uvh mypack-2.0-1.rpm Upgrades mypack.
rpm -qip mypack-1.2.2.rpm To query with details about the package.
rpm -qlp mypack-1.2.2.rpm Gives a list of files this package installs.
rpm -e mypack-1.2.2 Removes the package mypack-1.2.2.

Typically RPM packages come with binary files ready for installation so all you need to do is the install as in the line above. The compilation which is the last three steps in the tar example in the first section above don’t need to be done. If you get a source file rather than a binary file, you will need to do a compile of code and an installation. If you just do the binary installation, be sure you get the package from a reliable source so you don’t get lovely extras like trap doors, trojans, or viruses.

Setting Linux Print Spooling

Printing is supported by “lpd” the line printer spooler daemon, which you should activate to support print services. Once print services are setup, type “lpr ?s -Pprinter filename” where “printer” is the name of your printer (the default is lp). The ‘-s’ option tells lpr to use symbolic links to print the file rather than copying it to its own spool file. If the ‘-P’ option is left out, the default printer name will be assumed.

Print spooling can be set up easily in Redhat using the “printtool” configuration tool following the following steps:

  1. Type “startx” to enter an x windows session.
  2. Open a terminal under x windows
  3. Type “printtool” in the terminal and CR.
  4. Edit or add a printer. Note that lp is the default printer for the lpd daemon.
  5. You can make the name of the printer anything you want. Note: lp is default.
  6. The spool directory should be “var/spool/printername”
  7. The printer server name should be the name of the server computer that the printer is attached to. Example PRT_SRV1
  8. The print queue name is the name of the printer as the printer server computer perceives it. Example: HP_LASER1.
  9. Depending on the network and how the printer resource is shared you may or may not need a user name and password.

How it works:

  1. Note the file “/etc/printcap” defines what filter script file will be used to output the printfile. Type “man lpd” and “man printcap” for more information.
  2. The filter script gets its input from standard input sometimes using such commands as “cat -“, see the cat man page. It also uses “file -” to get a description of the input.
  3. On netware print servers, you must be logged on before it will work. I use the scripts from the section on “Network printing setup and use” to logon and type “neton username”.

Other useful commands for printing:

lpr – Prints a file to default lp printer
lpq – shows files to print in the print que
lpc – Line printer control program. Type “lpc status” to see status on all printers. This command can enable or disable printing or queuing.
lprm – Remove a job from the print queue using number reported by lpq. Ex: lprm 14
tunelp – A utility to optimize the printer. “tunelp /dev/lp -q” will display the IRQ for the device

The directory /var/spool/lpd contains a directory for every printer. This is where the print files are spooled.

To set up a printer on a parallel or serial port:
A printer on the first parallel port is probably /dev/lp0 or /dev/lp1.
To test the printer type “lptest > /dev/lp1” to send test output directly to the printer. If the printer is a postscript printer you need to send it a postscript file by typing “cat test.ps > /dev/lp1”. The lptest program is a utility made to test a printer.
If the printer is serial, output is directed to /dev/ttyS0 or /dev/ttyS1.

The /etc/printcap file:
The printcap file begins a comment line with #
Example:

ljet4|lp|ps|Postscript|600dpi 20MB memory|end of hall|local|LPT1:\
:lp=dev/lp0:rw:\
:sd=/var/spool/lpd/ljet4:mx#0:mc#0:pl#72:pw#85:\
:lf=/var/log/lpd-errs:if=/usr/local/cap/ljet4:

On the first line (virtual), the names of the printer are shown with each name separated by ‘|’.
Commands include:

  • The lp line is the device name for output (local printer).
  • rw is specified if the printer can send data back to the host through the device file. A network printer uses /dev/null.
  • mx – Sets the maximum size of a print job.
  • pl – page length.
  • pw – page width.
  • The sd line is the subdirectory the files are spooled in
  • The if line tells the input filter to use
  • br-baud rate for a serial port
  • sh-suppress header
  • rp-remote printer
  • rm-remote host that controls remote printer
  • rs- restrict access to local printers to users with an account
  • rg-restricted group that can use the printer
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s