Home / Alt manpages / paperconf(1)

  • paperconf(1)
  • User command
  • linux

Find and override the system paper size with paperconf

You will use paperconf to see the active paper setting, print dimensions in a useful unit, test a one-command override, and change the system default only when that is really what you want. Allow about ten minutes. You need a shell and the libpaper-utils package. The examples are read-only until the section that deliberately edits /etc/papersize.

The examples below were checked with libpaper-utils 1.1.29build1. The installed manual page is dated 24 April 2001, so treat the command output shown here as a version-specific observation rather than a promise that every newer libpaper release formats text identically.

1. Check which paper is active

Run paperconf without arguments:

$ paperconf
letter

The command prints the paper name and exits successfully. On this machine, /etc/papersize contains letter. Your result may be different.

To ask for the name explicitly, use -n. To capitalise its first letter for display, use -N:

$ paperconf -n
letter
$ paperconf -N
Letter

Checkpoint: if the name is not the one your application expects, stop here and inspect the precedence rules in the next step before editing a file.

2. Understand where the value comes from

With no command-line paper name, paperconf checks these sources in order:

  1. PAPERSIZE, if it is set;
  2. the file named by PAPERCONF, if that variable is set;
  3. /etc/papersize;
  4. the built-in fallback, letter.

This ordering explains a common trap: an environment variable can make a file edit appear to have no effect. Check the current environment with:

$ printf 'PAPERSIZE=%s\nPAPERCONF=%s\n' "${PAPERSIZE-}" "${PAPERCONF-}"
PAPERSIZE=
PAPERCONF=

Blank output here means the variables are unset or empty in this shell. If either contains a value, test with a clean command such as env -u PAPERSIZE -u PAPERCONF paperconf -n. This does not change your shell or any system file.

3. Inspect dimensions in the unit you need

The default size output uses PostScript points. Use -s for width followed by height, then choose centimetres, millimetres or inches with -c, -m or -i:

$ paperconf -s
612 792
$ paperconf -s -m
215.9 mm 279.4 mm
$ paperconf -s -i
8.5" 11"

For a single dimension, replace -s with -w for width or -h for height. The unit option affects size output, not the paper name:

$ paperconf -p A4 -n
a4
$ paperconf -p A4 -s -m
210 mm 297 mm

-p selects a named paper for that query; it does not write a new default. Paper names are normalised by the installed utility, which is why the input A4 is printed as a4.

4. Test an override without changing configuration

For a script, job or one-off check, set PAPERSIZE on that command only:

$ PAPERSIZE=A4 paperconf -s -m
210 mm 297 mm

This is usually the safest way to check how a program will behave. The variable lasts for that process and its children, not for later shell commands.

A per-user configuration file is another option. Put one paper name, such as A4, on its own line in a file you own, then point PAPERCONF at its full path:

$ PAPERCONF=/home/your-user/.config/paper-size paperconf -n
a4

Replace /home/your-user/.config/paper-size with the real file path. The file must contain the paper name, not a shell assignment such as PAPERSIZE=A4. If PAPERSIZE is also set, it wins over this file.

5. Change the system default deliberately

Edit /etc/papersize only if the default should change for users and programs that do not provide an override. This requires elevated privileges and changes system-wide behaviour. Before doing it, record the current value:

$ cat /etc/papersize
letter

Replace the file with a single valid paper name, for example:

$ printf '%s\n' A4 | sudo tee /etc/papersize
A4

Verify the effective result in a shell without overriding environment variables:

$ env -u PAPERSIZE -u PAPERCONF paperconf -n
a4

To undo this example, write back the value you recorded, or restore the file from your system's configuration backup. Do not remove /etc/papersize as a shortcut: when the file is absent, libpaper falls back to letter, which may silently change printing for other users.

6. Handle unknown names and failed checks

An unknown name is not silently accepted. A normal query reports the error and exits non-zero:

$ paperconf -p not-a-paper -n
paperconf: unknown paper `not-a-paper'
$ printf '%s\n' "$?"
2

The -z option also prints an unknown name, but still reports the error and returns a non-zero status. That is useful when a script must preserve the supplied name while detecting invalid input. Check the status immediately, before running another command.

Do not use sudo for ordinary queries. Use it only for the deliberate write to /etc/papersize. If a query fails unexpectedly, check the environment, the named PAPERCONF file's contents and readability, and then run paperconf -p A4 -s -m to separate a configuration problem from a paper-name problem.

Done means

  • You know the active paper name and have checked the command's exit status.
  • You can explain whether PAPERSIZE, PAPERCONF or /etc/papersize supplied it.
  • You can query width and height in points, centimetres, millimetres or inches.
  • One-off changes use PAPERSIZE rather than an unnecessary system edit.
  • Any change to /etc/papersize was verified and can be reversed using the recorded old value.