Resize a Linux Virtual Console with resizecons
You will change the kernel's idea of a Linux text console from the terminal, either by selecting a supported row count or by applying a previously saved video mode. The installed command comes from kbd 2.6.4-2ubuntu2 on the machine used for this guide. Allow roughly five minutes for a row-only change, or longer if you need to capture and test a complete video mode.
The route
Jump straight to the step you need, or tick off Done means at the end.
Before you start
This is for a Linux virtual console, such as tty1, not an ordinary terminal emulator running under a graphical desktop. The command can alter the display for all active virtual consoles and may load a different font. Work locally at the machine if possible, keep another login available for recovery, and save any important terminal output before changing the mode.
You need the resizecons program from the kbd package. Confirm what is installed without changing the console:
command -v resizecons
resizecons --version
On this installation, the second command prints the accepted forms and the supported row counts rather than a conventional version string. That output is useful: it confirms that this build accepts either a mode name or -lines followed by one of 25, 28, 30, 34, 36, 40, 44, 50 or 60.
Checkpoint: choose a row-only change
The lower-risk operation is changing only the number of rows. The current kbd implementation can attempt this directly, while a complete column-by-row mode requires hardware-specific settings. Choose a supported value that your display can show:
sudo resizecons -lines 50
Replace 50 with the required value from the usage output. sudo is shown because changing the kernel console layout usually needs root privileges. If your account already has the required privilege, omit it.
There is normally no success report to parse. Verify the terminal dimensions immediately:
stty size
Expected output has the form 50 80, although the column count depends on the existing video mode. If you are checking a particular console device, run the command while that virtual console is active. The utility also updates the terminal settings for active consoles in its normal range and sends a window-size notification to the selection program when its PID file is present.
Checkpoint: apply a saved video mode
Use the COLSxROWS form only when you have a mode file created by restoretextmode. The name is a path-like mode identifier, not a request for arbitrary dimensions. First save a known-working text mode, if you are at a suitable console and have permission:
sudo restoretextmode -w /tmp/console-mode
Then apply that saved mode with:
sudo resizecons /tmp/console-mode
In this form, resizecons invokes restoretextmode -r, so restoretextmode and its supporting svgalib functionality must be installed. The mode file must already exist and describe hardware that the command can control. Do not guess a filename such as 80x25 and expect it to work.
Safety boundaries and recovery
This command is not a harmless label change. The kernel first receives a resize request and reallocates console screen memory for all virtual consoles. That can fail if memory is unavailable. If the request succeeds but a later hardware, permission or font step fails, the display can be left in an untidy state. Do not use it during a remote-only recovery session where losing the visible console would remove your only diagnostic path.
Warning
A complete mode change writes video-card registers and can disrupt the console immediately. Test it at the machine, keep a second virtual console available with Ctrl+Alt+F2 where supported, and avoid running it while a critical foreground program depends on the current terminal dimensions.
If the screen becomes unreadable, switch to another virtual console and log in. Reapply a mode you know works, or restore the previous row setting:
sudo resizecons -lines 25
stty size
If the font is the only part that looks wrong, reload a suitable console font after the resize. The exact font file is distribution-specific, so inspect the installed setfont documentation and configuration rather than copying an unverified filename. A row-only change does not provide a universal undo command: recovery means selecting a known supported row count or restoring a previously saved mode.
Common failure modes
- Unsupported hardware: the utility does not work on every video adapter and is limited to x86 and x86_64 according to this manpage. On other hardware, investigate
fbsetor the platform's console tooling instead. - Permission denied: rerun the selected operation with
sudoonly if you trust the mode file and understand that the change affects the machine's virtual consoles. - Not enough console memory: reduce the number of allocated virtual consoles if you control the machine and have a planned maintenance window. Do not remove consoles blindly on a system that relies on them for recovery.
- Missing or invalid mode file: check the exact path and recreate it with
restoretextmode -wfrom a known-good text mode. A mode file from different hardware is not a portable display profile. - The screen looks wrong after success: reload the intended font with
setfont, then runstty sizeto distinguish a font problem from a terminal-size problem.
Done means
resizeconsis installed and its usage lists the row value you selected.- The command completed from a Linux virtual console with the required privileges.
stty sizereports the expected row count.- The console remains usable after any font reload.
- You know which supported row count or saved mode to use for recovery.