Subject: Jessie (8.0) - Unexpected behavior of "MATE Terminal" after reboot

From: Richard Owlett <[email-masked]>
Date: Wed, 21 Sep 2016 06:59:28 -0500

I'm learning the shell.
I experiment with test cases in "MATE Terminal"
The "up arrow" key is useful to recall previous command for editing.
I hadn't expected it when I found all instances of "MATE 
Terminal" share same history.

*HOWEVER* I found that history remains after a "power off", 
"boot" cycle.
That is *UNACCEPTABLE* for my purposes.
To start FRESH was the purpose of "power off", "boot" cycle.

BUG?
Workaround?

TIA

---

From: Peter Ludikovsky <[email-masked]>
Date: Wed, 21 Sep 2016 14:16:27 +0200

Hello,

Not a bug, but a feature since the first C shell release in 1978 [1],
which was copied to pretty much every shell created since (Korn
shell/ksh, Bourne again shell/bash, Z shell/zsh, …). The reason behind
it is that – since Unix predates most graphical user interfaces, and
most of the time the computers were accessed over slow modem lines – in
case of a disconnect you might want to know which commands you entered
last, and maybe re-run them with different parameters.

But really, this shouldn't influence your learning. After all, the shell
only remembers the history of entered commands, it does neither replay
those commands, nor save the state of the shell upon exit. Think of it
as kind of the URL history a browser saves. Just because the URL is
saved, it doesn't automatically load the page on startup. Depending on
the shell you're actually using, it might even be possible to
temporarily disable the shell history, akin to “Incognito Mode”.

Regards
/peter

[1] https://en.wikipedia.org/wiki/C_shell#History

On 09/21/2016 01:59 PM, Richard Owlett wrote:
> I hadn't expected it when I found all instances of "MATE Terminal" share
> same history.
> 
> *HOWEVER* I found that history remains after a "power off", "boot" cycle.

---

From: David <[email-masked]>
Date: Wed, 21 Sep 2016 22:06:43 +1000

> I'm learning the shell.

Which shell?

Try 'man whatever.shell.you.are.using' and read what it says about "history".

In bash for example, you can set HISTFILESIZE to zero.

---

From: Richard Owlett <[email-masked]>
Date: Wed, 21 Sep 2016 07:30:50 -0500

> On 21 September 2016 at 21:59, Richard Owlett <[email-masked]> wrote:

That may be an an even better question than meets the eye.

I have two use cases:
   1. the immediate one being whatever shell MATE terminal uses.
      Sub-question: When in an arbitrary terminal of an arbitrary 
Desktop Environment,
         how would I determine which shell is in use?
   2. The motivation for learning shell is to create a custom 
preseed.cfg file as per
      "B.5.3. Chainloading preconfiguration files" of 
_Installation Manual_.

---

From: Richard Owlett <[email-masked]>
Date: Wed, 21 Sep 2016 08:49:19 -0500

>       "B.5.3. Chainloading preconfiguration files" of

Thank you all for answers. They even prompted a few questions I 
didn't know I should have asked ;/

I have found:
   1. Mate Terminal uses bash.
   2. entering /bin/sh puts me in dash
      Which is what scripts placed in preseed.cfg use. [my 
motivation for journey]
      Makes the question of command history and variable 
persistence moot.

Later.

---

From: John Hasler <[email-masked]>
Date: Wed, 21 Sep 2016 08:18:36 -0500

Richard writes:
> When in an arbitrary terminal of an arbitrary Desktop Environment, how
> would I determine which shell is in use?

To find out what shell is the login shell type

echo $SHELL

To find out what shell you are running type

echo $0

To run the Korn shell type

ksh

To kill the shell you are currenting using type

control-D

To clear bash command history on logout truncate ~.bash_history in
~.bash_logout.

Note that desktop environments do not respect Unix conventions and
standards so some of the above may not work as expected in some DEs.
-- 
John Hasler 
[email-masked]
Elmwood, WI USA

---

From: Greg Wooledge <[email-masked]>
Date: Wed, 21 Sep 2016 09:24:03 -0400

> To find out what shell you are running type

imadev:~$ csh
% echo "$0"
No file for $0.

The world's a much bigger place than just the Bourne family of shells,
unfortunately.

ps -p $$   # works in csh too

---

From: John Hasler <[email-masked]>
Date: Wed, 21 Sep 2016 08:35:44 -0500

> No file for $0.

Well, that tells you that you are running something weird and
nonstandard such as csh.  But if you are running csh you already knew
that.

If

        echo $0

doesn't produce satisfactory results run

        ps

and examine the output.
-- 
John Hasler 
[email-masked]
Elmwood, WI USA

---

From: Greg Wooledge <[email-masked]>
Date: Wed, 21 Sep 2016 08:36:23 -0400

>   1. the immediate one being whatever shell MATE terminal uses.

Unless it's completely diverging from Unix standards, it should launch
your user account's shell as defined either by the $SHELL environment
variable, or by your entry in the passwd database.

>         how would I determine which shell is in use?

In my experience, the simplest way to see what shell you are in is to
run this command:

ps -p $$

This command "works" (for varying definitions) in Bourne-family shells,
csh-family shells, BSD systems, and System V systems.

But you'd also be well-served to check out the $SHELL variable, and
your own entry in /etc/passwd or whichever passwd database you happen
to be using, and to understand what it means.

---

From: [email-masked]
Date: Wed, 21 Sep 2016 14:04:10 +0200 (CEST)

De: "Richard Owlett" <[email-masked]>
> Workaround?

rm ~/.bash_history

HTH

---

From: Richard Owlett <[email-masked]>
Date: Wed, 21 Sep 2016 07:18:50 -0500

> De: "Richard Owlett" <[email-masked]>

It didn't :<
No such file seems to exist in any directory.
Is this a systemd thing?

---

From: Brad Rogers <[email-masked]>
Date: Wed, 21 Sep 2016 13:30:06 +0100

On Wed, 21 Sep 2016 07:18:50 -0500
Richard Owlett <[email-masked]> wrote:

Hello Richard,

>Is this a systemd thing?

No, it's a bash thing.  If you're not using bash (IDK what Mate's
terminal is based on) then it won't exist.  Look for something like
equivalent to see what you've got, if anything.

-- 
 Regards  _
         / )           "The blindingly obvious is
        / _)rad        never immediately apparent"
Keep your drink just give 'em the money
U & Ur Hand - P!nk