Linux Tips

Self Managed Systems

On a self managed linux system, the easiest to connect to the printhost server is to use cups client.

Depending on your flavor of linux and architecture, you use either aptitude or yum to install the cups-client packages as follows:

Run as root: `aptitude install cups-client`

or

Run as root: `yum install cup.x86_64`

Once the  cup client is installed.  Modify the /etc/cups/client.conf file as follows:

ServerName printhost.cs.brown.edu

You will need to authenticate with your LDAP credential every time you print if your local username and password is different than what the printhost server is expecting. 

Command Line Printing

The command lpr(1) sends a file to a printer. The CUPS version of lpr understands a variety of formats including, text, PostScript, and PDF. Many GUI programs, such as Mozilla and Acrobat, will print by passing arguments through LPR. Usually you can see the command the program will use after selecting Print from the File menu.

Your default printer is specified by your shell's PRINTER environment variable. For new users, this is set to bw1 in the .environment file in your home directory. To change your default printer, modify your PRINTER environment variable in the appropriate location.

Setting Print Options on the Command Line

For the common tasks of printing single-sided, on letterhead, and on transparency, we have modified the command-line lpr program to accept -s, -l, and -t, respectively. The full feature command set for CUPS are listed below and is available from man lpr. Some common printer options:

Printing non text/postscript documents from the command line

lpr acrobatdoc.pdf 

Printing to a certain printer (i.e. bw4)

lpr -Pbw4 mydocument

Setting the Custom paper size to 42.1 x 42.1 inches

lpr -o media=Custom.42.1x42.1in mydocument

Setting Duplex Printing (two-sided-long-edge is default)

lpr -o sides=one-sided mydocumentlpr -o sides=two-sided-long-edge mydocumentlpr -o sides=two-sided-short-edge mydocument

Setting the media type (duplex is on by default, so turn it off)

lpr -o media=Transparency -o sides=one-sided mydocumentlpr -o media=Letterhead -o sides=one-sided mydocument

Print on Letterhead for first page, Plain for remaining pages

lpr -o sides=one-sided -o 1:media=Letterhead -o media=Plain mydocument

Print multiple document pages on a printed page (N-Up)

lpr -o number-up=2 mydocumentlpr -o number-up=4 mydocument

Print only odd or even pages

lpr -o page-set=odd mydocumentlpr -o page-set=even mydocument

Print page ranges

lpr -o page-ranges=5 mydocumentlpr -o page-ranges=2-5 mydocumentlpr -o page-ranges=2-5,7-9 mydocument

Rotate page

lpr -o landscape mydocument

Set the percentage brightness

lpr -o brightness=120 mydocument

Set the Gamma correction (1000 is default)

lpr -o gamma=1700 mydocument

Print multiple copies

lpr -n num copies -o collate=True mydocument

Text Printing Options

lpr -o prettyprint mydocument.txtlpr -o cpi=10 mydocument.txtlpr -o lpi=8 mydocument.txtlpr -o columns=2 mydocument.txt

Setting Page Margins (in 1/72's of an Inch)

lpr -o page-left=72 -o page-right=72 -o page-top=72 -o page-bottom=72 mydocument.txt

Image Printing Options

lpr -o position=center myimage {center,top,left,right,top-left,top-right, bottom,bottom-left,bottom-right} lpr -o scaling=100 myimage (1-800%)lpr -o ppi=300 myimage (dots per inch)lpr -o hue=-10 myimage (-360 to 360)lpr -o saturation=110 myimage (0-200%)

Setting Default Options

The printing options above can also be used to set default options for future print jobs. Use the lpoptions command with the same arguments above. The options will be saved in the .lpoptions file in your home directory. The following example will set 1/2" margins and make text smaller:

lpoptions -o page-left=36 -o page-right=36 -o page-top=36 -o page-bottom=36 
lpoptions -o cpi=12
lpoptions -o lpi=7

To get all available options for a specific printer: 
lpoptions -p <printer name>

Cancelling Jobs

To cancel a job, use lprm and enter your LDAP password. Note that you have to cancel the job on the same printer you sent it to, specified with the -P option (example: lprm -P bw5). Each time you run lprm it deletes one job unless you give "-" as the last argument, in which case it deletes all your jobs.

Graphically Setting Print Options

To set printer options graphically, you may use the gtklp(1) command instead of lpr in exactly the same manner. After you click Print in your application, a tabbed window will pop up where you can set options such as letterhead and single-sided printing in a point-and-click manner. Most of the useful options are on the General tab.

By default, changes to the options presented in gtklp apply only to the current print job and not to subsequent print jobs. If you have a set of options that you wish to be able to reuse easily in the future, you can click on "Templates" at the bottom. To permanently change your default options for this printer, simply click "Save". To save a set of options for this printer that you only want to use occasionally, type a name for this set in the box labeled "Instance", and then click "New". You can modify or remove these named sets of options later by clicking "Templates" later.