5

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

Output of systemctl status

1
  • 5
    It's not bash that's doing it. Is it only systemctl 's behavior that changed? Commented Apr 8, 2017 at 11:42

3 Answers 3

10

The man page for systemctl (man systemctl) explains this behaviour clearly, and offers options to change it:

$SYSTEMD_PAGER Pager to use when --no-pager is not given; overrides $PAGER. If neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known pager implementations are tried in turn, including less(1) and more(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
0
7

More widely, you can define PAGER environment in your bash runtime config

# In .bashrc or .bash_profile

export PAGER='cat'
3

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

2
  • Is there a way to make the content of --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. Commented Feb 20, 2023 at 18:58
  • 1
    @Sнаđошƒаӽ No I don't think there is a built in way. For this to work, every program would need to build in support for this (Or support the PAGER environment parameter), and unfortunately they don't. Using dpkg --help | less is the best method that I know of. Commented Feb 21, 2023 at 23:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.