Set and Verify the Default Paper Size on Linux
You will set the paper size used by programs that read libpaper, then verify the resolved name and dimensions. The examples use libpaper and libpaper-utils version 1.1.29build1, installed on Debian or Ubuntu systems as the libpaper1 and libpaper-utils packages.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about five minutes. You need a shell, permission to read the current configuration, and sudo only for the system-wide change. This guide changes a small configuration value, not printer queues, document files or page layouts.
1. Check the current result
Start with the library's query command. Running it without arguments resolves the paper in this order: PAPERSIZE, the file named by PAPERCONF, /etc/papersize, then the built-in fallback letter.
$ paperconf
letter
$ paperconf -s
612 792
The size is printed as width followed by height in PostScript points unless you select another unit. On this machine, letter is 612 by 792 points. Your output may differ because a user or system setting may already be present.
Checkpoint: record both the name and the dimensions before changing anything:
$ paperconf -n
letter
$ paperconf -s -m
215.9 279.4
If paperconf is missing, install the package through your normal package-management process. Do not use sudo merely to query the setting.
2. Choose a recognised paper name
The common names include a3, a4, a5, b5, letter, legal, executive, note and 11x17. The file format accepts other names known to libpaper, but a consuming program may support fewer names.
Before changing the system, ask libpaper about the name you intend to use:
$ paperconf -p a4 -n
a4
$ paperconf -p a4 -s -m
210 297
If the name is unknown, add -z when checking so the command reports the problem on standard error and returns a non-zero status:
$ paperconf -p clearly-not-a-paper -z
clearly-not-a-paper
paperconf: ...
$ printf '%s\n' "$?"
non-zero status
The exact diagnostic text can vary. The useful result is the failed status. Do not put an unrecognised name into a shared configuration and hope each application will interpret it.
3. Set the system default
Use paperconfig with the validated name. This is the privileged step because it writes the system default, normally /etc/papersize, and may run scripts in /etc/libpaper.d after the change:
$ sudo paperconfig --paper a4
$ paperconf
a4
$ paperconf -s -m
210 297
The command normally prints no success message. The following unprivileged query is the checkpoint: it must resolve to a4 and report the expected dimensions.
Do not edit /etc/papersize while another administrator or configuration tool is managing the host. If you need to inspect the file without changing it, use:
$ sudo sed -n '1,20p' /etc/papersize
The file is deliberately simple. Whitespace and text from a # to the end of a line are ignored; the first paper name found is used. The name is case-insensitive for libpaper, although some applications that bypass the library may require a particular capitalisation.
4. Use a temporary override for one command
You do not need to change the system default when a single conversion, test or job needs another size. Set PAPERSIZE on that command only:
$ PAPERSIZE=letter paperconf -n
letter
$ paperconf -n
a4
The second query still sees the system setting because the environment assignment lasted for one process. This is a useful way to test software or run a one-off job without affecting other users.
For a longer-lived, user-specific override, point PAPERCONF at a file you control. Create it with a single value, then export the variable in the shell that launches the relevant program:
$ printf '%s\n' letter > /tmp/my-paper.conf
$ PAPERCONF=/tmp/my-paper.conf paperconf -n
letter
The PAPERCONF path must be a full path. Keep this file private to the application or user that needs the override. Remove the temporary file when the test is finished:
$ rm /tmp/my-paper.conf
That removal is safe only if the file is the temporary example above and no process still needs it. If you used a persistent file, unset PAPERCONF or change the launcher instead of deleting a shared configuration.
5. Recover when a program disagrees
First check the environment in the same shell that starts the application:
$ printf 'PAPERSIZE=%s\nPAPERCONF=%s\n' "${PAPERSIZE-}" "${PAPERCONF-}"
$ paperconf -n
a4
An exported PAPERSIZE or PAPERCONF takes precedence over /etc/papersize, so it can make a correct system change appear ineffective. Check the application's documentation too: the manual page warns that some programs do not use libpaper and may not ignore comments, whitespace or case in the same way.
To undo the system change, run paperconfig with the previous validated name. For example, if the recorded old value was letter:
$ sudo paperconfig --paper letter
$ paperconf -n
letter
Keep the old value until the new setting has been tested by the document-producing applications that matter to you. A paper-size setting does not resize existing documents or force a printer to accept a particular sheet.
Done means
paperconf -nreports the intended resolved paper name.paperconf -sor a unit-qualified query confirms its dimensions.- System changes were made through
sudo paperconfig --paper NAMEwith a validated name. - One-off jobs use
PAPERSIZEorPAPERCONFwithout unintentionally changing the host default. - Any disagreement has been checked against environment overrides and applications that do not use libpaper.