SEGURANCA Como limpar a tela ao efetuar logout

De Gentoo Linux Wiki

Este artigo faz parte da seção de Segurança.

Tabela de conteúdo

[editar] Recommended method

[editar] Using vi

You can use /etc/issue to clear the terminal by putting ansi escape sequences in the first line.

vi /etc/issue

Enter insert mode. In the first line type (without the spaces):

CTRL-V CTRL-ESC [2J CTRL-V CTRL-ESC [f

you should get this: {{Box File|/etc/issue|

^[[2J^[[f
This is \n.\O (\s \m \r) \t

}}

This resets the terminal before the issue message is displayed. Note that copy-pasting won't work, you should type that sequence.

If CTRL-ESC brings ProcessTable in KDE try another method using vi:

clear >> /etc/issue
vi /etc/issue
Gdd1GPZZ

The last line tells vi to move the character sequence generated by clear command to the first line of file, saves the file and exits.

[editar] Using nano

clear >> /etc/issue

Now, open /etc/issue with nano or your favorite editor and move the code to the top of the file. nano /etc/issue

you should end up with this: {{Box File|/etc/issue|

^[[H^[[2J
This is \n.\O (\s \m \r) \t 

}}

[editar] Other methods

[editar] Method 1

If you are working on a server, or a public workstation, for example in an university, you might want to make sure no-one reads screen-content which is left over by your last session after typing "logout".

To achieve this, you simply need to add the command clear to your ~/.bash_logout.

echo "clear" >> ~/.bash_logout

should do the trick.

[editar] Method 2

A variant to method 1 is appending this to /etc/profile (or ~/.bashrc)

Arquivo: /etc/profile or ~/.bashrc
alias exit="clear && logout"
  • Note: When I used "clear" in my ~/.bash_logout I could still use Shift + PageUp to scroll up in the terminal. A solution that works for me is to replace "clear" with "reset" in ~/.bash_logout.

[editar] Method 3

A variant on Method 2 is to append this to /etc/profile (or ~/.bashrc)

Arquivo: /etc/profile or ~/.bashrc
alias exit="reset && logout"

[editar] Method 4

If you do clear on logout some of the last lines still will be available "SHIFT+PageUP". This will clear the history.

Arquivo: /etc/inittab
...
# getty-programs for the normal runlevels
# <id>:<runlevels>:<action>:<process>
# The "id" field  MUST be the same as the last
# characters of the device (after "tty").
#1:2345:respawn:/sbin/mingetty --noclear tty1
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
...
  • Note: I use mingetty
  • Note: "SHIFT+PageUP" will not work if you changed console to another one and then back to original one, i.e. you are at "Alt+F1" then "Alt+F2" and back to "Alt+F1".

[editar] Method 5

Not the best way, but it works.

cp /etc/issue /etc/issue.bak; clear > /etc/issue; cat /etc/issue.bak >> /etc/issue; rm /etc/issue.bak

I use a script to generate my /etc/issue every 15 minutes, so having a 'clear > /etc/issue' at the top was what i did to have this affect.

[editar] Method 6

Another dirty way is to flush the screen with a lot of random chars from /dev/urandom before logging out.

cat /dev/urandom & sleep 3; logout

After this, the whole scrollback buffer is overwritten with random chars.

[editar] Method 7

Clean and easy: add "trap clear 0" to your /etc/profile - cheerz :)

Ferramentas pessoais