4

There is a reset command I can use in bash, which I think is part of core-utils. Does it clean up the RAM used by previous commands from the Terminal session?

I mean everything written into the terminal and memory used by commands.

4

From man reset:

reset - reinitialization
       When  invoked  as  reset,  tset  sets  cooked and echo modes, turns off
       cbreak and raw modes, turns on newline translation and resets any unset
       special  characters  to  their default values before doing the terminal
       initialization described above.  This is useful after  a  program  dies
       leaving a terminal in an abnormal state.[...]

So it completely reinitializes the terminal session you are in, purging all data (it will still be stored it ~/.bash_history though, delete that if you're feeling secretive). If you just want to reload the settings, you can run . ~/.bashrc. If you just want to have a blank terminal window without resetting, run clear or hit Ctrl + L.

| improve this answer | |
  • CTRL + L combo for clear shortcut – sdkks Jan 20 '17 at 17:06
2

reset comes from ncurses, not coreutils.

It resets plenty of properties of the terminal, but by far not all. Also in many terminal emulators, including recent versions of gnome-terminal, it also clears the entire scrollback buffer in the sense that it's no longer accessible via the UI, e.g. using the scrollbar.

I'm not sure what you mean by RAM (I mean, I obviously know what it stands for, but I don't quite get what aspect you are asking).

A terminal emulator is free to implement the desired behavior in any way it wants to. E.g. it might use a programming language or library with garbage collection, in which case you hardly have any control when the data actually disappears from RAM.

GNOME Terminal has a very complex implementation of the scrollback history. A bit more than the normally visible lines (i.e. assuming you did not scroll back) are kept in RAM. After some point, the data that's been scrolled out is converted to a different format (still in RAM), batched up to larger blocks, once a complete block is filled up then is compressed, encrypted and written on disk. (All this assuming vte-0.40 or newer; older versions were quite different.) But it is still in the process's RAM until something else (i.e. even more data in the terminal) takes its place. Also there's a read cache where it might be present.

But all this should only be relevant if you examine the process's memory footprint for reasons like trying to understand what data can be recovered if someone breaks into a live system and gets root access. In that sense, there's no guarantee whatsoever that data visually wiped out by reset is not recoverable at all. It might still be there in RAM, or on disk (encrypted with a key that's in RAM until you close the given terminal tab).

If you're a regular user examining the user visible behavior of the process then this user visible behavior is all you should care about, it's irrelevant (and is quite hard to follow) when the data is actually wiped out for good from the process's RAM.

So, let me assume that you don't actually care about RAM, you care about the user visible behavior for "regular" users. If so then yes, after a reset there's no way to bring back that data.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.