Set the Linux Default Paper Size with paperconfig
You will set the default paper size used by programs that read libpaper's configuration, then verify the value without guessing from a graphical printer setting. This guide uses paperconfig from libpaper-utils 1.1.29build1, as installed on this machine.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell and, for the system-wide example, an account permitted to write /etc/papersize. The examples change a configuration file, so record the existing value before you begin. The test using PAPERCONF is suitable for a user-owned temporary file and does not need elevated privileges.
1. Check the installed command
Start with read-only checks. These commands do not need sudo:
$ command -v paperconfig
/usr/sbin/paperconfig
$ dpkg-query -W -f='${Package} ${Version}\n' libpaper-utils
libpaper-utils 1.1.29build1
$ paperconfig --version
paperconfig version 1.0 by Yves Arrouye <[email protected]>
The option names are --paper for a named non-interactive selection and --force to force the interactive selection. --help and --version only report information.
Checkpoint
If paperconfig is missing, stop here and install or repair the package through your normal system administration process. Do not replace it with an unrelated printer utility.
2. Record the current system value
Read the current file before changing it:
$ sudo cat /etc/papersize
letter
The output is host-specific. On this machine the value is letter. The file contains the system-wide default, and libpaper uses letter as a fallback if the file does not exist. The paper name is case-insensitive to libpaper, although other programs may be less forgiving.
If you cannot use sudo, you can still test the command safely in step 4. Do not create a replacement file somewhere else and assume system programs will read it.
3. Set the system-wide paper size
Choose a paper name supported by your applications. Common names include a4, a3, a5, b5, letter, legal, executive, note and 11x17. Set A4 with elevated privileges:
$ sudo paperconfig --paper A4
This writes the selected name to the configured paper file. On the standard installation that is /etc/papersize, so the command normally requires root permission. The installed command accepts the mixed-case input above and writes the normalised value:
$ cat /etc/papersize
a4
Warning
This is a persistent system change. It affects software that consults libpaper, not every application that has its own document or printer preference. If your host runs package-provided integration hooks, changing the value can also run executable scripts in /etc/libpaper.d. Review that directory before making a change on a tightly controlled system:
$ sudo find /etc/libpaper.d -maxdepth 1 -type f -printf '%f\n' 2>/dev/null
The directory may be empty, and other packages may add scripts. The scripts are run with run-parts, so their filenames must meet that tool's naming rules.
4. Test a selection without touching /etc
For a dry run, point PAPERCONF at a file you own. paperconfig rewrites that file with the chosen system paper value:
$ test_file=$(mktemp /tmp/paperconfig-test.XXXXXX)
$ printf '%s\n' letter > "$test_file"
$ PAPERCONF="$test_file" paperconfig --paper A4
$ cat "$test_file"
a4
The temporary file is only a test target. Remove it after inspection with the exact path printed by mktemp:
$ rm -- "$test_file"
The PAPERCONF environment variable is a full path, not a directory. It is useful when testing a deployment or a script, but it does not permanently redirect other processes after the shell exits.
Checkpoint
If the file still contains the old value after a valid selection, check that PAPERCONF names the file you inspected and that the command returned success. Do not use sudo as a first response: it can cause the test to write a different file as root.
5. Verify the value applications will read
Use paperconf to ask libpaper for the effective value:
$ paperconf
a4
This reads the configuration used by libpaper. A program can still override it with its own settings. The libpaper lookup also honours the PAPERSIZE environment variable before the configuration file, so a shell or service environment can make paperconf report something different from /etc/papersize:
$ PAPERSIZE=letter paperconf
letter
That override is temporary for this command. If a service gives an unexpected result, inspect its environment and unit configuration before changing the system default.
6. Handle invalid names and recover
An invalid name is rejected. In this installed version, the command prints an error and returns status 3; it leaves the target file unchanged:
$ PAPERCONF="$test_file" paperconfig --paper definitely-not-a-paper
paperconfig: "definitely-not-a-paper" is not a known paper name
$ printf 'status: %s\n' "$?"
status: 3
Do not script against the exact wording of the diagnostic. Check for a zero exit status and verify the resulting value. If a system-wide change was wrong, restore the value you recorded in step 2 by choosing that value explicitly:
$ sudo paperconfig --paper letter
$ paperconf
letter
That recovery also runs the change hooks when the value changes. It is safer than editing /etc/papersize by hand because it uses the command's normal notification path.
7. Use interactive selection only when it helps
Run the interactive picker with elevated privileges when you want to choose from the available prompts:
$ sudo paperconfig --force
--force deliberately asks for a selection even when the current paper name is already valid. That is useful when correcting an old choice, but it can be a distraction in automation. For scripts and repeatable provisioning, prefer --paper NAME, check its status, and verify with paperconf.
Do not combine a paper name with --force; the synopsis treats them as alternative modes. Also avoid running the interactive form from a non-interactive service, where it can wait for input or fail without a useful operator present.
Done means
- The installed
libpaper-utilsversion and command syntax are known. - The old system value was recorded before making a persistent change.
paperconfig --paper NAMEcompleted successfully with the required privilege.paperconfreports the intended effective value, with anyPAPERSIZEoverride understood.- An invalid name was treated as an error, not as a request to guess.
- You know how to restore the previous value and have considered any
/etc/libpaper.dhooks.