Why is there a call to `clear_console` in `~/.bash_logout`?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
When I log in with the same user on tty1
and tty2
and start an X server session on tty1
- as soon as I log out of tty2
, the X server session on tty1
crashes.
This seems to be a known bug:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834270
- https://groups.google.com/forum/#!topic/linux.debian.user/2G71U8P8c3Q
As you can read in the bug reports, the problem lies with the call to clear_console
in ~/.bash_logout
. If I remove that line, everything works fine.
My question:
I didn't notice any changes. (Obviously apart from the X server not crashing any more.) The console is being cleared as I log out - regardless of me removing that line. So, what is the call to clear_console
there for in the first place?
bash debian ubuntu xorg x-server
add a comment |Â
up vote
1
down vote
favorite
When I log in with the same user on tty1
and tty2
and start an X server session on tty1
- as soon as I log out of tty2
, the X server session on tty1
crashes.
This seems to be a known bug:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834270
- https://groups.google.com/forum/#!topic/linux.debian.user/2G71U8P8c3Q
As you can read in the bug reports, the problem lies with the call to clear_console
in ~/.bash_logout
. If I remove that line, everything works fine.
My question:
I didn't notice any changes. (Obviously apart from the X server not crashing any more.) The console is being cleared as I log out - regardless of me removing that line. So, what is the call to clear_console
there for in the first place?
bash debian ubuntu xorg x-server
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When I log in with the same user on tty1
and tty2
and start an X server session on tty1
- as soon as I log out of tty2
, the X server session on tty1
crashes.
This seems to be a known bug:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834270
- https://groups.google.com/forum/#!topic/linux.debian.user/2G71U8P8c3Q
As you can read in the bug reports, the problem lies with the call to clear_console
in ~/.bash_logout
. If I remove that line, everything works fine.
My question:
I didn't notice any changes. (Obviously apart from the X server not crashing any more.) The console is being cleared as I log out - regardless of me removing that line. So, what is the call to clear_console
there for in the first place?
bash debian ubuntu xorg x-server
When I log in with the same user on tty1
and tty2
and start an X server session on tty1
- as soon as I log out of tty2
, the X server session on tty1
crashes.
This seems to be a known bug:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834270
- https://groups.google.com/forum/#!topic/linux.debian.user/2G71U8P8c3Q
As you can read in the bug reports, the problem lies with the call to clear_console
in ~/.bash_logout
. If I remove that line, everything works fine.
My question:
I didn't notice any changes. (Obviously apart from the X server not crashing any more.) The console is being cleared as I log out - regardless of me removing that line. So, what is the call to clear_console
there for in the first place?
bash debian ubuntu xorg x-server
edited Jun 21 at 11:18
asked Jun 21 at 11:09
Jayjayyy
1338
1338
add a comment |Â
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
2
down vote
I think this has to do with privacy and security. It wouldn't be wise to leave open to anyone's eyes what you did in your ended session. On my Debian the full entry in .bash_logout
is:
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
$SHLVL
is 1 when it's the first shell in the chain. (You can start a new shell from a shell and this increments the SHLVL
.) Once you're ending the first session and so passing the console and prompt to anyone, the console should keep the contents of your session inaccessible to unauthorised eyes, and so it does.
1
Well, I agree: privacy and security have to be the reason why one would clear the console. But why callclear_console
if the console is being cleared anyway?
â Jayjayyy
Jun 21 at 11:43
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
add a comment |Â
up vote
2
down vote
Your tty is being cleared due to a configuration in the init system. Nowadays, probably systemd
.
for systemd set
TTYVTDisallocate
to no.
to achieve this, run
systemctl edit getty@tty1
and enter the code
below[Service]
TTYVTDisallocate=no
https://askubuntu.com/questions/58097/how-can-i-remove-the-clear-screen-before-login/781923#781923
A comment points to a longer page which also mentions a configuration which could be used under sysvinit: the --noclear
option of getty
.
http://mywiki.wooledge.org/SystemdNoClear
Finally, it sounds like the clear feature in getty
(and hence the --noclear
option of getty) has not existed in all versions.
As the system administrator, you can configure the console to always be cleared before showing the login prompt. The easiest way to do that is to use mingetty instead of getty; you lose support for serial consoles but gain a few features such as screen clearing.
-- How to clear terminal after logging out? answer posted 2010.
Therefore, bash_logout might have been the only way to clear the screen without switching to a different getty.
add a comment |Â
up vote
2
down vote
The world wants you to clean your screen.
As I said at https://unix.stackexchange.com/a/233855/5132 and indeed in the indirectly referenced mailing list discussion ⺠â¦
Wanting not to clear a virtual terminal between log-off and subsequent log-on is very much swimming against the tide, as Greg Wooledge and others have discovered. The presence of sensitive output from privileged users, or bosses, remaining after log-off has been a security problem for Unices (and indeed other timesharing remote-access operating systems) since the 1970s, and it takes a lot of effort to undo all of the things that people have put in to avert this problem. As you have observed, they have put in several overlapping mechanisms that do this.
- Many systems have a
clear_console
command in their shell logout scripts as standard. (This is problematic in its own right, as it doesn't play well with graphical programs running on kernel virtual terminal #1, and doesn't work with any other kinds of terminals, virtual or real.)This command has to be removed.
- The default in getty programs aimed at virtual terminals, such as
mingetty
, is to clear the terminal. (It does this before log-on, meaning that terminal output can remain unerased if a TTY login service is stopped. Ironically, this functionality would have been better placed inlogin
, which thanks to the necessities of PAM is still running at log-off.)The
--noclear
option has to be deployed to disable this. On systemd operating systems this involves writing one or more unit file override files, changing theExecStart
setting, or simply pointingautovt@.service
at a local unit file of one's own devising. - systemd's supplied
getty@.service
template service unit setsTTYVTDisallocate=yes
which instructs systemd to clear a kernel virtual terminal. (This again doesn't work with any other kinds of terminals, not even user-space virtual terminals, as partly reflected in its name.)This too has to be removed, again with an override or a different service template pointed to by
autovt@.service
.
They are not entirely overlapping, of course. mingetty
isn't useful for real terminals connected via serial devices; clear_console
is, oddly, part of the Bourne Again shell package and isn't invoked by people who have the Korn, Z, Almquist, Fish, Watanabe, or other shell as their user account's interactive login shell; and the systemd TTYVTDisallocate
mechanism has no applicability to non-systemd operating systems.
As I said in the mailing list discussion several years ago, console_clear
is doubly unnecessary. Since 2011 the Linux built-in terminal emulator has supported the ED 3
control sequence for clearing the scrollback buffer, so the mucking around with switching virtual terminals that has these detrimental side-effects isn't necessary in the first place. I added a console-clear
command to the nosh toolset several years ago, that emits this control sequence (and is thus usable with more than just the Linux built-in terminal emulator, as well as working over a remote connection). The ncurses clear
command also nowadays knows to emit the relevant control sequences, if terminfo says so.
And of course console-terminal-emulator
clears its display buffer at terminal hangup as standard.
Further reading
- https://unix.stackexchange.com/a/375784/5132
- Greg Wooledge (2014-04-08). Stop Clearing My God Damned Console. Greg's Wiki.
- Jonathan de Boyne Pollard (2015-08-22). System freeze with multiple ttys in Debian Jessie. 55D8CF3E.6090704@NTLWorld.com. debian-user.
- https://unix.stackexchange.com/a/318297/5132
- Jonathan de Boyne Pollard (2018).
console-terminal-emulator
. nosh Guide. Softwares. - Jonathan de Boyne Pollard (2018).
console-clear
. nosh Guide. Softwares. - https://unix.stackexchange.com/a/316279/5132
- Carsten Hey (2015-08-09). zsh: please clear console on logout (if recommended config is used). Debian Bug #704968.
add a comment |Â
up vote
2
down vote
According to dlocate
, clear_console
is part of the (Debian) bash package. It is not part of the upstream bash
sources. The package changelog tells you when/where it came from:
-- Matthias Klose Thu, 23 Mar 2006 01:16:22 +0100
bash (3.1-3) unstable; urgency=low
...
Merge from Ubuntu:
* clear_console: New helper program to clear the console, including
the scrollback buffer.
* /etc/skel/.bash_logout: Install it again and use clear_console.
Ubuntu #29405. Closes: #331504.
The referenced bug-reports give the reason why it was added:
Ubuntu #29405, January 2006 'clear' is not run before 'exit'
When logging out of a F1-F6 terminal, all of your existing output of activies are left on the screen even when the next login screen appears. The screen should be cleared before the new login appears, so private output won't be viewed by other users.
Debian #331504, October 2005 bash: Please provide a default /etc/skel/.bash_logout
It would be nice if bash would provide a default .bash_logout in /etc/skel
for users to use by default to clean up the screen when login through
console this is common request, specially in multi-user environments where
people don't want others to see what they were working on.
By the way, that was mentioned in conjunction with ncurses here:
Red Hat #815790 [RFE-privacy] clear the console, mentioning
Debian #376841 please add clear_console to ncurses-bin
The former was resolved by adapting a feature from xterm
patch #107 in 1999 (for the Linux console), while the latter went nowhere because of license incompatibilities.
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
I think this has to do with privacy and security. It wouldn't be wise to leave open to anyone's eyes what you did in your ended session. On my Debian the full entry in .bash_logout
is:
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
$SHLVL
is 1 when it's the first shell in the chain. (You can start a new shell from a shell and this increments the SHLVL
.) Once you're ending the first session and so passing the console and prompt to anyone, the console should keep the contents of your session inaccessible to unauthorised eyes, and so it does.
1
Well, I agree: privacy and security have to be the reason why one would clear the console. But why callclear_console
if the console is being cleared anyway?
â Jayjayyy
Jun 21 at 11:43
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
add a comment |Â
up vote
2
down vote
I think this has to do with privacy and security. It wouldn't be wise to leave open to anyone's eyes what you did in your ended session. On my Debian the full entry in .bash_logout
is:
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
$SHLVL
is 1 when it's the first shell in the chain. (You can start a new shell from a shell and this increments the SHLVL
.) Once you're ending the first session and so passing the console and prompt to anyone, the console should keep the contents of your session inaccessible to unauthorised eyes, and so it does.
1
Well, I agree: privacy and security have to be the reason why one would clear the console. But why callclear_console
if the console is being cleared anyway?
â Jayjayyy
Jun 21 at 11:43
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
add a comment |Â
up vote
2
down vote
up vote
2
down vote
I think this has to do with privacy and security. It wouldn't be wise to leave open to anyone's eyes what you did in your ended session. On my Debian the full entry in .bash_logout
is:
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
$SHLVL
is 1 when it's the first shell in the chain. (You can start a new shell from a shell and this increments the SHLVL
.) Once you're ending the first session and so passing the console and prompt to anyone, the console should keep the contents of your session inaccessible to unauthorised eyes, and so it does.
I think this has to do with privacy and security. It wouldn't be wise to leave open to anyone's eyes what you did in your ended session. On my Debian the full entry in .bash_logout
is:
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
$SHLVL
is 1 when it's the first shell in the chain. (You can start a new shell from a shell and this increments the SHLVL
.) Once you're ending the first session and so passing the console and prompt to anyone, the console should keep the contents of your session inaccessible to unauthorised eyes, and so it does.
answered Jun 21 at 11:32
Tomasz
8,01552560
8,01552560
1
Well, I agree: privacy and security have to be the reason why one would clear the console. But why callclear_console
if the console is being cleared anyway?
â Jayjayyy
Jun 21 at 11:43
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
add a comment |Â
1
Well, I agree: privacy and security have to be the reason why one would clear the console. But why callclear_console
if the console is being cleared anyway?
â Jayjayyy
Jun 21 at 11:43
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
1
1
Well, I agree: privacy and security have to be the reason why one would clear the console. But why call
clear_console
if the console is being cleared anyway?â Jayjayyy
Jun 21 at 11:43
Well, I agree: privacy and security have to be the reason why one would clear the console. But why call
clear_console
if the console is being cleared anyway?â Jayjayyy
Jun 21 at 11:43
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
@Jayjayyy If it does clear anyway, then I see no reason for not removing it. But be careful if you change some other parameters, which change this behaviour (see sourcejedi's answer).
â Tomasz
Jun 21 at 11:49
add a comment |Â
up vote
2
down vote
Your tty is being cleared due to a configuration in the init system. Nowadays, probably systemd
.
for systemd set
TTYVTDisallocate
to no.
to achieve this, run
systemctl edit getty@tty1
and enter the code
below[Service]
TTYVTDisallocate=no
https://askubuntu.com/questions/58097/how-can-i-remove-the-clear-screen-before-login/781923#781923
A comment points to a longer page which also mentions a configuration which could be used under sysvinit: the --noclear
option of getty
.
http://mywiki.wooledge.org/SystemdNoClear
Finally, it sounds like the clear feature in getty
(and hence the --noclear
option of getty) has not existed in all versions.
As the system administrator, you can configure the console to always be cleared before showing the login prompt. The easiest way to do that is to use mingetty instead of getty; you lose support for serial consoles but gain a few features such as screen clearing.
-- How to clear terminal after logging out? answer posted 2010.
Therefore, bash_logout might have been the only way to clear the screen without switching to a different getty.
add a comment |Â
up vote
2
down vote
Your tty is being cleared due to a configuration in the init system. Nowadays, probably systemd
.
for systemd set
TTYVTDisallocate
to no.
to achieve this, run
systemctl edit getty@tty1
and enter the code
below[Service]
TTYVTDisallocate=no
https://askubuntu.com/questions/58097/how-can-i-remove-the-clear-screen-before-login/781923#781923
A comment points to a longer page which also mentions a configuration which could be used under sysvinit: the --noclear
option of getty
.
http://mywiki.wooledge.org/SystemdNoClear
Finally, it sounds like the clear feature in getty
(and hence the --noclear
option of getty) has not existed in all versions.
As the system administrator, you can configure the console to always be cleared before showing the login prompt. The easiest way to do that is to use mingetty instead of getty; you lose support for serial consoles but gain a few features such as screen clearing.
-- How to clear terminal after logging out? answer posted 2010.
Therefore, bash_logout might have been the only way to clear the screen without switching to a different getty.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Your tty is being cleared due to a configuration in the init system. Nowadays, probably systemd
.
for systemd set
TTYVTDisallocate
to no.
to achieve this, run
systemctl edit getty@tty1
and enter the code
below[Service]
TTYVTDisallocate=no
https://askubuntu.com/questions/58097/how-can-i-remove-the-clear-screen-before-login/781923#781923
A comment points to a longer page which also mentions a configuration which could be used under sysvinit: the --noclear
option of getty
.
http://mywiki.wooledge.org/SystemdNoClear
Finally, it sounds like the clear feature in getty
(and hence the --noclear
option of getty) has not existed in all versions.
As the system administrator, you can configure the console to always be cleared before showing the login prompt. The easiest way to do that is to use mingetty instead of getty; you lose support for serial consoles but gain a few features such as screen clearing.
-- How to clear terminal after logging out? answer posted 2010.
Therefore, bash_logout might have been the only way to clear the screen without switching to a different getty.
Your tty is being cleared due to a configuration in the init system. Nowadays, probably systemd
.
for systemd set
TTYVTDisallocate
to no.
to achieve this, run
systemctl edit getty@tty1
and enter the code
below[Service]
TTYVTDisallocate=no
https://askubuntu.com/questions/58097/how-can-i-remove-the-clear-screen-before-login/781923#781923
A comment points to a longer page which also mentions a configuration which could be used under sysvinit: the --noclear
option of getty
.
http://mywiki.wooledge.org/SystemdNoClear
Finally, it sounds like the clear feature in getty
(and hence the --noclear
option of getty) has not existed in all versions.
As the system administrator, you can configure the console to always be cleared before showing the login prompt. The easiest way to do that is to use mingetty instead of getty; you lose support for serial consoles but gain a few features such as screen clearing.
-- How to clear terminal after logging out? answer posted 2010.
Therefore, bash_logout might have been the only way to clear the screen without switching to a different getty.
answered Jun 21 at 11:43
sourcejedi
18.1k22375
18.1k22375
add a comment |Â
add a comment |Â
up vote
2
down vote
The world wants you to clean your screen.
As I said at https://unix.stackexchange.com/a/233855/5132 and indeed in the indirectly referenced mailing list discussion ⺠â¦
Wanting not to clear a virtual terminal between log-off and subsequent log-on is very much swimming against the tide, as Greg Wooledge and others have discovered. The presence of sensitive output from privileged users, or bosses, remaining after log-off has been a security problem for Unices (and indeed other timesharing remote-access operating systems) since the 1970s, and it takes a lot of effort to undo all of the things that people have put in to avert this problem. As you have observed, they have put in several overlapping mechanisms that do this.
- Many systems have a
clear_console
command in their shell logout scripts as standard. (This is problematic in its own right, as it doesn't play well with graphical programs running on kernel virtual terminal #1, and doesn't work with any other kinds of terminals, virtual or real.)This command has to be removed.
- The default in getty programs aimed at virtual terminals, such as
mingetty
, is to clear the terminal. (It does this before log-on, meaning that terminal output can remain unerased if a TTY login service is stopped. Ironically, this functionality would have been better placed inlogin
, which thanks to the necessities of PAM is still running at log-off.)The
--noclear
option has to be deployed to disable this. On systemd operating systems this involves writing one or more unit file override files, changing theExecStart
setting, or simply pointingautovt@.service
at a local unit file of one's own devising. - systemd's supplied
getty@.service
template service unit setsTTYVTDisallocate=yes
which instructs systemd to clear a kernel virtual terminal. (This again doesn't work with any other kinds of terminals, not even user-space virtual terminals, as partly reflected in its name.)This too has to be removed, again with an override or a different service template pointed to by
autovt@.service
.
They are not entirely overlapping, of course. mingetty
isn't useful for real terminals connected via serial devices; clear_console
is, oddly, part of the Bourne Again shell package and isn't invoked by people who have the Korn, Z, Almquist, Fish, Watanabe, or other shell as their user account's interactive login shell; and the systemd TTYVTDisallocate
mechanism has no applicability to non-systemd operating systems.
As I said in the mailing list discussion several years ago, console_clear
is doubly unnecessary. Since 2011 the Linux built-in terminal emulator has supported the ED 3
control sequence for clearing the scrollback buffer, so the mucking around with switching virtual terminals that has these detrimental side-effects isn't necessary in the first place. I added a console-clear
command to the nosh toolset several years ago, that emits this control sequence (and is thus usable with more than just the Linux built-in terminal emulator, as well as working over a remote connection). The ncurses clear
command also nowadays knows to emit the relevant control sequences, if terminfo says so.
And of course console-terminal-emulator
clears its display buffer at terminal hangup as standard.
Further reading
- https://unix.stackexchange.com/a/375784/5132
- Greg Wooledge (2014-04-08). Stop Clearing My God Damned Console. Greg's Wiki.
- Jonathan de Boyne Pollard (2015-08-22). System freeze with multiple ttys in Debian Jessie. 55D8CF3E.6090704@NTLWorld.com. debian-user.
- https://unix.stackexchange.com/a/318297/5132
- Jonathan de Boyne Pollard (2018).
console-terminal-emulator
. nosh Guide. Softwares. - Jonathan de Boyne Pollard (2018).
console-clear
. nosh Guide. Softwares. - https://unix.stackexchange.com/a/316279/5132
- Carsten Hey (2015-08-09). zsh: please clear console on logout (if recommended config is used). Debian Bug #704968.
add a comment |Â
up vote
2
down vote
The world wants you to clean your screen.
As I said at https://unix.stackexchange.com/a/233855/5132 and indeed in the indirectly referenced mailing list discussion ⺠â¦
Wanting not to clear a virtual terminal between log-off and subsequent log-on is very much swimming against the tide, as Greg Wooledge and others have discovered. The presence of sensitive output from privileged users, or bosses, remaining after log-off has been a security problem for Unices (and indeed other timesharing remote-access operating systems) since the 1970s, and it takes a lot of effort to undo all of the things that people have put in to avert this problem. As you have observed, they have put in several overlapping mechanisms that do this.
- Many systems have a
clear_console
command in their shell logout scripts as standard. (This is problematic in its own right, as it doesn't play well with graphical programs running on kernel virtual terminal #1, and doesn't work with any other kinds of terminals, virtual or real.)This command has to be removed.
- The default in getty programs aimed at virtual terminals, such as
mingetty
, is to clear the terminal. (It does this before log-on, meaning that terminal output can remain unerased if a TTY login service is stopped. Ironically, this functionality would have been better placed inlogin
, which thanks to the necessities of PAM is still running at log-off.)The
--noclear
option has to be deployed to disable this. On systemd operating systems this involves writing one or more unit file override files, changing theExecStart
setting, or simply pointingautovt@.service
at a local unit file of one's own devising. - systemd's supplied
getty@.service
template service unit setsTTYVTDisallocate=yes
which instructs systemd to clear a kernel virtual terminal. (This again doesn't work with any other kinds of terminals, not even user-space virtual terminals, as partly reflected in its name.)This too has to be removed, again with an override or a different service template pointed to by
autovt@.service
.
They are not entirely overlapping, of course. mingetty
isn't useful for real terminals connected via serial devices; clear_console
is, oddly, part of the Bourne Again shell package and isn't invoked by people who have the Korn, Z, Almquist, Fish, Watanabe, or other shell as their user account's interactive login shell; and the systemd TTYVTDisallocate
mechanism has no applicability to non-systemd operating systems.
As I said in the mailing list discussion several years ago, console_clear
is doubly unnecessary. Since 2011 the Linux built-in terminal emulator has supported the ED 3
control sequence for clearing the scrollback buffer, so the mucking around with switching virtual terminals that has these detrimental side-effects isn't necessary in the first place. I added a console-clear
command to the nosh toolset several years ago, that emits this control sequence (and is thus usable with more than just the Linux built-in terminal emulator, as well as working over a remote connection). The ncurses clear
command also nowadays knows to emit the relevant control sequences, if terminfo says so.
And of course console-terminal-emulator
clears its display buffer at terminal hangup as standard.
Further reading
- https://unix.stackexchange.com/a/375784/5132
- Greg Wooledge (2014-04-08). Stop Clearing My God Damned Console. Greg's Wiki.
- Jonathan de Boyne Pollard (2015-08-22). System freeze with multiple ttys in Debian Jessie. 55D8CF3E.6090704@NTLWorld.com. debian-user.
- https://unix.stackexchange.com/a/318297/5132
- Jonathan de Boyne Pollard (2018).
console-terminal-emulator
. nosh Guide. Softwares. - Jonathan de Boyne Pollard (2018).
console-clear
. nosh Guide. Softwares. - https://unix.stackexchange.com/a/316279/5132
- Carsten Hey (2015-08-09). zsh: please clear console on logout (if recommended config is used). Debian Bug #704968.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The world wants you to clean your screen.
As I said at https://unix.stackexchange.com/a/233855/5132 and indeed in the indirectly referenced mailing list discussion ⺠â¦
Wanting not to clear a virtual terminal between log-off and subsequent log-on is very much swimming against the tide, as Greg Wooledge and others have discovered. The presence of sensitive output from privileged users, or bosses, remaining after log-off has been a security problem for Unices (and indeed other timesharing remote-access operating systems) since the 1970s, and it takes a lot of effort to undo all of the things that people have put in to avert this problem. As you have observed, they have put in several overlapping mechanisms that do this.
- Many systems have a
clear_console
command in their shell logout scripts as standard. (This is problematic in its own right, as it doesn't play well with graphical programs running on kernel virtual terminal #1, and doesn't work with any other kinds of terminals, virtual or real.)This command has to be removed.
- The default in getty programs aimed at virtual terminals, such as
mingetty
, is to clear the terminal. (It does this before log-on, meaning that terminal output can remain unerased if a TTY login service is stopped. Ironically, this functionality would have been better placed inlogin
, which thanks to the necessities of PAM is still running at log-off.)The
--noclear
option has to be deployed to disable this. On systemd operating systems this involves writing one or more unit file override files, changing theExecStart
setting, or simply pointingautovt@.service
at a local unit file of one's own devising. - systemd's supplied
getty@.service
template service unit setsTTYVTDisallocate=yes
which instructs systemd to clear a kernel virtual terminal. (This again doesn't work with any other kinds of terminals, not even user-space virtual terminals, as partly reflected in its name.)This too has to be removed, again with an override or a different service template pointed to by
autovt@.service
.
They are not entirely overlapping, of course. mingetty
isn't useful for real terminals connected via serial devices; clear_console
is, oddly, part of the Bourne Again shell package and isn't invoked by people who have the Korn, Z, Almquist, Fish, Watanabe, or other shell as their user account's interactive login shell; and the systemd TTYVTDisallocate
mechanism has no applicability to non-systemd operating systems.
As I said in the mailing list discussion several years ago, console_clear
is doubly unnecessary. Since 2011 the Linux built-in terminal emulator has supported the ED 3
control sequence for clearing the scrollback buffer, so the mucking around with switching virtual terminals that has these detrimental side-effects isn't necessary in the first place. I added a console-clear
command to the nosh toolset several years ago, that emits this control sequence (and is thus usable with more than just the Linux built-in terminal emulator, as well as working over a remote connection). The ncurses clear
command also nowadays knows to emit the relevant control sequences, if terminfo says so.
And of course console-terminal-emulator
clears its display buffer at terminal hangup as standard.
Further reading
- https://unix.stackexchange.com/a/375784/5132
- Greg Wooledge (2014-04-08). Stop Clearing My God Damned Console. Greg's Wiki.
- Jonathan de Boyne Pollard (2015-08-22). System freeze with multiple ttys in Debian Jessie. 55D8CF3E.6090704@NTLWorld.com. debian-user.
- https://unix.stackexchange.com/a/318297/5132
- Jonathan de Boyne Pollard (2018).
console-terminal-emulator
. nosh Guide. Softwares. - Jonathan de Boyne Pollard (2018).
console-clear
. nosh Guide. Softwares. - https://unix.stackexchange.com/a/316279/5132
- Carsten Hey (2015-08-09). zsh: please clear console on logout (if recommended config is used). Debian Bug #704968.
The world wants you to clean your screen.
As I said at https://unix.stackexchange.com/a/233855/5132 and indeed in the indirectly referenced mailing list discussion ⺠â¦
Wanting not to clear a virtual terminal between log-off and subsequent log-on is very much swimming against the tide, as Greg Wooledge and others have discovered. The presence of sensitive output from privileged users, or bosses, remaining after log-off has been a security problem for Unices (and indeed other timesharing remote-access operating systems) since the 1970s, and it takes a lot of effort to undo all of the things that people have put in to avert this problem. As you have observed, they have put in several overlapping mechanisms that do this.
- Many systems have a
clear_console
command in their shell logout scripts as standard. (This is problematic in its own right, as it doesn't play well with graphical programs running on kernel virtual terminal #1, and doesn't work with any other kinds of terminals, virtual or real.)This command has to be removed.
- The default in getty programs aimed at virtual terminals, such as
mingetty
, is to clear the terminal. (It does this before log-on, meaning that terminal output can remain unerased if a TTY login service is stopped. Ironically, this functionality would have been better placed inlogin
, which thanks to the necessities of PAM is still running at log-off.)The
--noclear
option has to be deployed to disable this. On systemd operating systems this involves writing one or more unit file override files, changing theExecStart
setting, or simply pointingautovt@.service
at a local unit file of one's own devising. - systemd's supplied
getty@.service
template service unit setsTTYVTDisallocate=yes
which instructs systemd to clear a kernel virtual terminal. (This again doesn't work with any other kinds of terminals, not even user-space virtual terminals, as partly reflected in its name.)This too has to be removed, again with an override or a different service template pointed to by
autovt@.service
.
They are not entirely overlapping, of course. mingetty
isn't useful for real terminals connected via serial devices; clear_console
is, oddly, part of the Bourne Again shell package and isn't invoked by people who have the Korn, Z, Almquist, Fish, Watanabe, or other shell as their user account's interactive login shell; and the systemd TTYVTDisallocate
mechanism has no applicability to non-systemd operating systems.
As I said in the mailing list discussion several years ago, console_clear
is doubly unnecessary. Since 2011 the Linux built-in terminal emulator has supported the ED 3
control sequence for clearing the scrollback buffer, so the mucking around with switching virtual terminals that has these detrimental side-effects isn't necessary in the first place. I added a console-clear
command to the nosh toolset several years ago, that emits this control sequence (and is thus usable with more than just the Linux built-in terminal emulator, as well as working over a remote connection). The ncurses clear
command also nowadays knows to emit the relevant control sequences, if terminfo says so.
And of course console-terminal-emulator
clears its display buffer at terminal hangup as standard.
Further reading
- https://unix.stackexchange.com/a/375784/5132
- Greg Wooledge (2014-04-08). Stop Clearing My God Damned Console. Greg's Wiki.
- Jonathan de Boyne Pollard (2015-08-22). System freeze with multiple ttys in Debian Jessie. 55D8CF3E.6090704@NTLWorld.com. debian-user.
- https://unix.stackexchange.com/a/318297/5132
- Jonathan de Boyne Pollard (2018).
console-terminal-emulator
. nosh Guide. Softwares. - Jonathan de Boyne Pollard (2018).
console-clear
. nosh Guide. Softwares. - https://unix.stackexchange.com/a/316279/5132
- Carsten Hey (2015-08-09). zsh: please clear console on logout (if recommended config is used). Debian Bug #704968.
edited Jun 21 at 16:43
answered Jun 21 at 16:28
JdeBP
27.9k459133
27.9k459133
add a comment |Â
add a comment |Â
up vote
2
down vote
According to dlocate
, clear_console
is part of the (Debian) bash package. It is not part of the upstream bash
sources. The package changelog tells you when/where it came from:
-- Matthias Klose Thu, 23 Mar 2006 01:16:22 +0100
bash (3.1-3) unstable; urgency=low
...
Merge from Ubuntu:
* clear_console: New helper program to clear the console, including
the scrollback buffer.
* /etc/skel/.bash_logout: Install it again and use clear_console.
Ubuntu #29405. Closes: #331504.
The referenced bug-reports give the reason why it was added:
Ubuntu #29405, January 2006 'clear' is not run before 'exit'
When logging out of a F1-F6 terminal, all of your existing output of activies are left on the screen even when the next login screen appears. The screen should be cleared before the new login appears, so private output won't be viewed by other users.
Debian #331504, October 2005 bash: Please provide a default /etc/skel/.bash_logout
It would be nice if bash would provide a default .bash_logout in /etc/skel
for users to use by default to clean up the screen when login through
console this is common request, specially in multi-user environments where
people don't want others to see what they were working on.
By the way, that was mentioned in conjunction with ncurses here:
Red Hat #815790 [RFE-privacy] clear the console, mentioning
Debian #376841 please add clear_console to ncurses-bin
The former was resolved by adapting a feature from xterm
patch #107 in 1999 (for the Linux console), while the latter went nowhere because of license incompatibilities.
add a comment |Â
up vote
2
down vote
According to dlocate
, clear_console
is part of the (Debian) bash package. It is not part of the upstream bash
sources. The package changelog tells you when/where it came from:
-- Matthias Klose Thu, 23 Mar 2006 01:16:22 +0100
bash (3.1-3) unstable; urgency=low
...
Merge from Ubuntu:
* clear_console: New helper program to clear the console, including
the scrollback buffer.
* /etc/skel/.bash_logout: Install it again and use clear_console.
Ubuntu #29405. Closes: #331504.
The referenced bug-reports give the reason why it was added:
Ubuntu #29405, January 2006 'clear' is not run before 'exit'
When logging out of a F1-F6 terminal, all of your existing output of activies are left on the screen even when the next login screen appears. The screen should be cleared before the new login appears, so private output won't be viewed by other users.
Debian #331504, October 2005 bash: Please provide a default /etc/skel/.bash_logout
It would be nice if bash would provide a default .bash_logout in /etc/skel
for users to use by default to clean up the screen when login through
console this is common request, specially in multi-user environments where
people don't want others to see what they were working on.
By the way, that was mentioned in conjunction with ncurses here:
Red Hat #815790 [RFE-privacy] clear the console, mentioning
Debian #376841 please add clear_console to ncurses-bin
The former was resolved by adapting a feature from xterm
patch #107 in 1999 (for the Linux console), while the latter went nowhere because of license incompatibilities.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
According to dlocate
, clear_console
is part of the (Debian) bash package. It is not part of the upstream bash
sources. The package changelog tells you when/where it came from:
-- Matthias Klose Thu, 23 Mar 2006 01:16:22 +0100
bash (3.1-3) unstable; urgency=low
...
Merge from Ubuntu:
* clear_console: New helper program to clear the console, including
the scrollback buffer.
* /etc/skel/.bash_logout: Install it again and use clear_console.
Ubuntu #29405. Closes: #331504.
The referenced bug-reports give the reason why it was added:
Ubuntu #29405, January 2006 'clear' is not run before 'exit'
When logging out of a F1-F6 terminal, all of your existing output of activies are left on the screen even when the next login screen appears. The screen should be cleared before the new login appears, so private output won't be viewed by other users.
Debian #331504, October 2005 bash: Please provide a default /etc/skel/.bash_logout
It would be nice if bash would provide a default .bash_logout in /etc/skel
for users to use by default to clean up the screen when login through
console this is common request, specially in multi-user environments where
people don't want others to see what they were working on.
By the way, that was mentioned in conjunction with ncurses here:
Red Hat #815790 [RFE-privacy] clear the console, mentioning
Debian #376841 please add clear_console to ncurses-bin
The former was resolved by adapting a feature from xterm
patch #107 in 1999 (for the Linux console), while the latter went nowhere because of license incompatibilities.
According to dlocate
, clear_console
is part of the (Debian) bash package. It is not part of the upstream bash
sources. The package changelog tells you when/where it came from:
-- Matthias Klose Thu, 23 Mar 2006 01:16:22 +0100
bash (3.1-3) unstable; urgency=low
...
Merge from Ubuntu:
* clear_console: New helper program to clear the console, including
the scrollback buffer.
* /etc/skel/.bash_logout: Install it again and use clear_console.
Ubuntu #29405. Closes: #331504.
The referenced bug-reports give the reason why it was added:
Ubuntu #29405, January 2006 'clear' is not run before 'exit'
When logging out of a F1-F6 terminal, all of your existing output of activies are left on the screen even when the next login screen appears. The screen should be cleared before the new login appears, so private output won't be viewed by other users.
Debian #331504, October 2005 bash: Please provide a default /etc/skel/.bash_logout
It would be nice if bash would provide a default .bash_logout in /etc/skel
for users to use by default to clean up the screen when login through
console this is common request, specially in multi-user environments where
people don't want others to see what they were working on.
By the way, that was mentioned in conjunction with ncurses here:
Red Hat #815790 [RFE-privacy] clear the console, mentioning
Debian #376841 please add clear_console to ncurses-bin
The former was resolved by adapting a feature from xterm
patch #107 in 1999 (for the Linux console), while the latter went nowhere because of license incompatibilities.
answered Jun 21 at 23:10
Thomas Dickey
49k583154
49k583154
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451069%2fwhy-is-there-a-call-to-clear-console-in-bash-logout%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password