After a recent update bash seems to always output to less, which is resulting in pagination for many commands. Does anyone know how to turn less off?
Example output for systemctl status
After a recent update bash seems to always output to less, which is resulting in pagination for many commands. Does anyone know how to turn less off?
Example output for systemctl status
The man page for systemctl (man systemctl) explains this behaviour clearly, and offers options to change it:
$SYSTEMD_PAGERPager to use when--no-pageris not given; overrides$PAGER. If neither$SYSTEMD_PAGERnor$PAGERare set, a set of well-known pager implementations are tried in turn, includingless(1) andmore(1), until one is found. If no pager implementation is discovered no pager is invoked. Setting this environment variable to an empty string or the value "cat" is equivalent to passing--no-pager.
So in your case the solution is to set the environment variable when you log in:
export SYSTEMD_PAGER=cat
More widely, you can define PAGER environment in your bash runtime config
# In .bashrc or .bash_profile
export PAGER='cat'
I often log into a system where it's a bad idea to change ~/root/.bashrc, /etc/profile, etc. And I don't always remember the parameter name SYSTEMD_PAGER.
So, as a lazy hack I simply pipe the output through cat or less (my preferred pager), like so:
systemctl status | cat
systemctl status | less
This trick for cat works for many other programs as well. For example, if I don't want to deal with how info navigates it's pages, I simply do this:
info bash | less
--help always be piped to less automatically, without me piping it to less? E.g. I want dpkg --help to be interpreted as dpkg --help | less automatically. Same for all --help commands.
PAGER environment parameter), and unfortunately they don't. Using dpkg --help | less is the best method that I know of.