Linux: pstree formatting

Today one of our developers came to me to discuss a problem and I wanted to show him something on one of our Linux machines. To check a process, I ran pstree and noticed that the formatting of the output was all wrong:

simon@atlas:~$ pstree
initââ¬âacpid
     ââapache2âââ10*[apache2]
     ââatd
[..]
     âârsyslogdâââ3*[{rsyslogd}]
     ââsshdââ¬âsshdâââbashâââping
     â      ââsshdâââbashâââpstree
     â      ââsshdâââsshdâââsh
     ââudevdâââ2*[udevd]

This is obviously just a cosmetical problem and the output is quite hard to read. When encountering something like this, the first guess would be that the encoding is somehow wrong. When checking the environment variables with env, we find that LANG is set to “en_US.UTF-8”.

So to get the correctly formatted output, we unset the LANG environment variable using unset LANG. After doing so, the output is now no longer cluttered and displayed correctly:

simon@atlas:~$ unset LANG
simon@atlas:~$ pstree
init-+-acpid
     |-apache2---10*[apache2]
     |-atd
[..]
     |-rsyslogd---2*[{rsyslogd}]
     |-sshd-+-sshd---bash---ping
     |      |-sshd---bash---pstree
     |      `-sshd---sshd---sh
     `-udevd---2*[udevd]

Alternative: Someone in the comments noted that you can also use

$ export LANG=ASCII

as an alternative to set the correct character set. I assume if no LANG is set, ASCII is used.

Hello world

My name is Simon Krenger, I am a Technical Account Manager (TAM) at Red Hat. I advise our customers in using Kubernetes, Containers, Linux and Open Source.

Elsewhere

  1. GitHub
  2. LinkedIn
  3. GitLab