You are not logged in.

#1 2025-07-03 07:39:24

Roberto2
Member
Registered: 2025-07-02
Posts: 9

LXterminal is leaving garbage files in home directory

I am using LXDE with LXTerminal 0.4.1  on Linux arch 6.15.4-arch2-1.

Using LXTerminal I often have some (> 3 ?) tabs open.
After
-  /usr/bin/reboot
or
- shutdown due to low battery
some new empty files do appear:

robert@arch:~(0)$ ls  -lart .bash*.tmp
-rw------- 1 robert robert 0 Jul  2 16:16 .bash_history-02337.tmp
-rw------- 1 robert robert 0 Jul  2 16:16 .bash_history-02306.tmp
-rw------- 1 robert robert 0 Jul  2 16:16 .bash_history-02290.tmp
-rw------- 1 robert robert 0 Jul  2 16:19 .bash_history-01246.tmp
-rw------- 1 robert robert 0 Jul  2 16:19 .bash_history-01230.tmp
-rw------- 1 robert robert 0 Jul  2 16:28 .bash_history-00949.tmp
-rw------- 1 robert robert 0 Jul  2 16:28 .bash_history-01189.tmp
-rw------- 1 robert robert 0 Jul  3 13:56 .bash_history-12478.tmp
-rw------- 1 robert robert 0 Jul  3 13:56 .bash_history-12462.tmp
-rw------- 1 robert robert 0 Jul  3 13:56 .bash_history-12446.tmp
-rw------- 1 robert robert 0 Jul  3 13:59 .bash_history-01239.tmp
-rw------- 1 robert robert 0 Jul  3 13:59 .bash_history-01221.tmp
-rw------- 1 robert robert 0 Jul  3 13:59 .bash_history-01151.tmp
robert@arch:~(0)$

This is not a big problem - it's good practice to check and close all terminal tabs before shutting down the computer.

It looks like this amount of files only can rise and never will be deleted. To get rid of them it could help to add

 
for f in ~/.bash_history-[0-9][0-9][0-9][0-9][0-9].tmp; do [[ ! -s $f ]] && rm $f ; done

into

 
 ~/.config/lxsession/LXDE/autostart

But it looks like a mistake in LXTerminal itself, so it should be corrected there ? wink

Offline

#2 2025-07-09 11:33:21

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,306
Website

Re: LXterminal is leaving garbage files in home directory

Please post the output of

$ stat ~/.bash_history
$ wc -l ~/.bash_history

See also: https://bbs.archlinux.org/viewtopic.php?id=236034


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#3 2025-07-10 06:40:13

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

$ stat ~/.bash_history
  File: /home/robert/.bash_history
  Size: 14528     	Blocks: 32         IO Block: 4096   regular file
Device: 8,3	Inode: 525473      Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/  robert)   Gid: ( 1000/  robert)
Access: 2025-07-10 13:11:27.869166169 +0700
Modify: 2025-07-10 13:11:27.857166168 +0700
Change: 2025-07-10 13:11:27.858548197 +0700
 Birth: 2025-07-10 13:11:27.855166168 +0700

$  wc -l ~/.bash_history
500 /home/robert/.bash_history

Last edited by Roberto2 (2025-07-10 06:50:13)

Offline

#4 2025-07-10 07:16:59

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,306
Website

Re: LXterminal is leaving garbage files in home directory

Yeah, and now compare that line count to

$ echo $HISTSIZE

Try running

$ history -a

and / or

$ history -w

And consider clearing your history with

$ rm ~/.bash_history

Last edited by schard (2025-07-10 07:22:25)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#5 2025-07-10 11:35:40

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

robert@arch:~(0)$ wc -l ~/.bash_history
500 /home/robert/.bash_history
robert@arch:~(0)$ history -a
robert@arch:~(0)$ wc -l ~/.bash_history
501 /home/robert/.bash_history

The bash_history will be cut to 500 lines again at (normal) closing or opening a new tab in  lxterminal.

Yes, I did  "rm .bash_history" ,  I made a few  tests with reboots:  I was not able to reproduce the error (while the line count of .bash_history was less than 500). After filling it up (to 500 lines) again I was able to reproduce the error.

At new reboot i logged in (on command line) as user root and checked the user's home directory: yes the new strange files where already there. This indicates the files are produced at shutdown time. It indicates also they are not a result of interaction between the initial text terminal login (and call of startx) and the gui  LXterminal.


I was not able to reproduce the empty error files when i killed the gui (alt-ctrl Backspace).

Offline

#6 2025-07-10 14:42:39

seth
Member
Registered: 2012-09-03
Posts: 65,914

Re: LXterminal is leaving garbage files in home directory

printenv

Is this only lxterminal? Doesn't happen w/ xterm?

Online

#7 2025-07-11 06:23:49

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

sorry, I never use xterm. At boot time I login on VGA text console, there I do a manual "startx". Then I stay inside the GUI,  where I only use LXTerminal.

here is the printenv:

SHELL=/bin/bash
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg
XDG_MENU_PREFIX=lxde-
LANGUAGE=en_US:en
_LXSESSION_PID=1023
XDG_DATA_HOME=/home/robert/.local/share
XDG_CONFIG_HOME=/home/robert/.config
DESKTOP_SESSION=LXDE
EDITOR=/usr/bin/vim
GTK_MODULES=canberra-gtk-module
XDG_SEAT=seat0
PWD=/tmp
LOGNAME=robert
XDG_SESSION_TYPE=tty
XAUTHORITY=/home/robert/.Xauthority
WINDOWPATH=1
MOTD_SHOWN=pam
HOME=/home/robert
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=LXDE
VTE_VERSION=8003
XDG_SESSION_CLASS=user
TERM=xterm-256color
USER=robert
VISUAL=/usr/bin/vim
DISPLAY=:0.0
SHLVL=3
XDG_VTNR=1
XDG_SESSION_ID=1
XDG_RUNTIME_DIR=/run/user/1000
PS1=${debian_chroot:+($debian_chroot)}\[\e[32;40m\]\u@\h:\w($?)\$\[\e[00m\]
QUOTING_STYLE=literal
DEBUGINFOD_URLS=https://debuginfod.archlinux.org
LC_ALL=en_US.UTF-8
XDG_DATA_DIRS=/usr/share/gdm:/var/lib/menu-xdg:/home/robert/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/robert/bin:/home/robert/bin
SAL_USE_VCLPLUGIN=gtk
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/spool/mail/robert
OLDPWD=/home/robert
_=/usr/bin/printenv

here is my lxterminal.conf: https://paste.c-net.org/DeferScale

Thanks for the help!

Offline

#8 2025-07-11 06:50:45

seth
Member
Registered: 2012-09-03
Posts: 65,914

Re: LXterminal is leaving garbage files in home directory

Please use [code][/code] tags, not "quote" tags. Edit your post in this regard.
There's nothing suspicious in the posted data, except:

PS1=${debian_chroot:+($debian_chroot)}\[\e[32;40m\]\u@\h:\w($?)\$\[\e[00m\] 

Where is this coming from?
Are you running debian or did you copy some debian bashrc?

sorry, I never use xterm.

The plan woul be to try. You can also go for one of the more hip and fancy ones like alacritty or kitty, but please stay away from anything using VTE.
We need to isolate whether this is coming from bash or the TE.

Also

there I do a manual "startx"

Though I'm not really sure how it could cause /this/ weirdness, see the last link below and in doubt post your xinitrc.

Online

#9 2025-07-11 11:22:36

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

the strange prompt:
sorry for confusing prompt: the first sentence of my initial question is still valid: ("I am using LXDE with LXTerminal 0.4.1  on Linux arch 6.15.4-arch2-1.)  This prompt is an historical one given to me (and not understood) around 20 years before which survived some linux-installations. I used it, because the standard prompt after installation did not show the exit value of the last command.  I never took the time to understand why I thought it serves me well: It results in the form I like: user name @ machine : path (exit value) $ (like now "roberto@arch:/tmp(0)$" ) - that is what I want.

see my "~/.xinitrc" : https://paste.c-net.org/HeadwayFeller

test row
My suspicion is, the error has something to to with open tabs in LXTerminal: it feels like more open tabs are there the more strange files appear. And never more strange files appear than the amount of open tabs before.
I installed kitty 0.42.1 (+ system update to arch 6.15.6-arch1-1)  because there i can open more sessions parallel.
It runs and at start I get the same error like in Arch Linux Forum /  [SOLVED] Can't use kitty terminal , but kitty runs (I did not deinstall xf86-video-intel as advised there)
----------
Test: 2 times I opened kitty, split the window into 4, entered into each window 3 single commands: "ls" + "echo x" + "ls".  Then reboot (without closing the window)
Result: no strange files
---------
Test: 3  times kitty, open 4 separate  complete screen (lets say "tabs" / with ctrl-sh-Enter and ctrl-shift-(left or right) to change. Same input like above. Then reboot (without closing the window)
Result: no strange files
---------
Test: 5 times open LXterminal, open 4 tabs, same input like above. Then reboot (without closing the window)
Result: strange empty files: first: 2 files, second: 3 files, third: 3 files, 4th: 0 (zero) files, 5th: 1 file
-----------------
Test:  1 time (only)
In my .bashrc there is "HISTCONTROL=ignoredups:ignorespace". Ignore duplicate lines means, that the program should not just add 3 commands of the tabs (ls; echo x; ls + ls; echo x; ls, ...) to the .bashrc, because  no double "ls"-entries should be produced. 
To check if double entries are the cause I changed the inputs:
Again 4 tabs. Each tab 3 Entries.
-  tab 1: echo 11; echo 12; echo 13
-  tab 2: echo 14; echo 15: echo 16;
-  tab 3: echo 17; echo 18; echo19,
-  tab 4 echo 20; echo 21; echo 22.
Result: 2 strange empty files:

this is the end of my bash history:

startx
echo 11
echo 12
echo 13
echo 20 
echo 21
echo 22

Result:
Entries for tab 2 and for tab 3 (with input echo 14 - echo 19) are missing - and 2 strange empty files appeared. This might indicate LXTerminal has a problem dealing with multi-tabs.

Last edited by Roberto2 (2025-07-11 11:24:15)

Offline

#10 2025-07-11 16:24:26

seth
Member
Registered: 2012-09-03
Posts: 65,914

Re: LXterminal is leaving garbage files in home directory

Does lxterminal inject a different $BASH_HISTORY in subsequent tabs?
Possibly caused by VTE3, rather than lxterminal itself.

Online

#11 2025-07-12 08:39:52

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

seth wrote:

Does lxterminal inject a different $BASH_HISTORY in subsequent tabs?

Why not? Every terminal emulation manages the command-line history of the session (typically in-memory) and the external ~/.bash_history.  At the end of the terminal emulation program the command line history is appended to the ~/.bash_history. This ensures: Retrieving last command from history you see is always the last command of 1. your session (and 2.  ~/.bash_history)  and parallel session activities do not interfere. Options of the history command (-a, -r, -w,...) deal exact with the old commands in session history and ~/.bash_history.
I imagine: It makes sense to have a temporary working file at hand in case the command-line history of the session gets too big to handle. The location of this temporary file in public /tmp might be a security question. So putting them into the users home directory may make sense.

my test: more reboot time?
If there is a reboot with an open terminal emulation it should first receive the terminal signals SIGTERM and there is a restricted time to act. I suppose LXTerminal does not get enough time finish: my last test showed, that of the 4 open sessions in only 2 the sessions-command-line history was added to the ~/.bash_history, and  2 of these strange files where created. I am running my system on a real HD (not SSD) - this slows down file operations.

It looks like there is enough shutdown time (my reboots only take seconds):

robert@arch:~(0)$ id -u
1000
robert@arch:~(0)$ systemctl show user@1000.service | grep TimeoutStopUSec
TimeoutStopUSec=2min

But maybe LXDE or X are quicker shutting down than LXTerminal.

rainer@arch:~(0)$ grep KillUserProcesses /etc/systemd/logind.conf
#KillUserProcesses=no

I uncommented (activated) this line (to 'KillUserProcesses=no') and (did a reboot to activate it and) started a new test.  - I tested the same way like the last one in my posting before. (LXterminal with  4 tabs. Each tab 3 Entries)
Result:
Entries of 3 tabs are stored in .bash_history. One strange empty file appeared

So this does not prove the error has something to do with SIGTERM  reboot time  => the issue might be more complex than just shutdown time, or that KillUserProcesses didn't entirely resolve it as expected ... ;-)

Offline

#12 2025-07-12 08:55:36

seth
Member
Registered: 2012-09-03
Posts: 65,914

Re: LXterminal is leaving garbage files in home directory

Why not?

I'm asking whether that's the case, not having a debate about its sensibility.

Iff lxterminal/vte3 sets per-tab bash histories there's no wondering where those files are coming from.
You'd (well, the lxterminal/vte3 devs) then have to come up with strategies to actually make use of those - esp. assuming the numbers are the tab shells PIDs…
You'd start w/ a completely different and empty history every single time…
Do you have HISTTIMEFORMAT set so the history entries in those files have timestamps (what would at least theoretically allow them to be merged at some point)
Do the individual histories get merged into bash_history at some point (look at the files)?
Might then just be a failure to clean things up afterwards.

For context:
https://man.archlinux.org/man/bash.1#HISTORY

Online

#13 2025-07-12 11:05:23

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

seth wrote:

I'm asking whether that's the case, not having a debate about its sensibility.

- ups sorry for my misanderstanding.

seth wrote:

You'd start w/ a completely different and empty history every single time…

different ~/.bash_history: sure - But not empty: the file it is always filled to the ($HISTSIZE) maximum (500).  I think less entries is a  just the special case of new installed system.

seth wrote:

Do you have HISTTIMEFORMAT set

No, it is not set.
But I get the file dates: If testing with reboot results in Error:  the strange new upcoming files do have the (almost) same timestamp than the ~/.bash_history.

seth wrote:

Do the individual histories get merged

Not merged by timestamp.  The moment  a session is closed, the complete command-line history of the session is added to the ~/.bash_history.
Example: If you have 2 commands in a session "ls file" and the following "rm file"  then (after session close (anytime)) you should always have (somewhere) in ~/.bash_history the entry "ls file" exactly followed by "rm file". I want to say: The moment you work with more than one terminal session parallel the stored commands (of all sessions together) are normally not  in time order (why do you open a parallel session if you work is sequential?).

seth wrote:

Might then just be a failure to clean things up afterwards.

Yes, I see it the same way.
If you've got an terminal open and you pull the plug you cannot expect that the session-command-line history is added to the ~/.bash_history. This job is part of an orderly shutdown.
My tests shows: Under the condition: LXTerminal has some tabs open (= more than 1 session). If then I reboot the computer:  LXTerminal often does not add the session-history of all the (before open-)sessions into ~/.bash_history. AND: For each missing tab one strange empty + hidden file (like ".bash_history-01151.tmp") appears.

It is bad behavior to boot the computer while terminal sessions are open. If LXTerminal then does not get the time to save all the session-command-line histories - this may be acceptable. Then  (I think) the problem can be reduced to an Error inside the the Error Handling:  The programmers should try to find an approach where these irritating file entries don't appear.

Offline

#14 2025-07-12 14:15:42

seth
Member
Registered: 2012-09-03
Posts: 65,914

Re: LXterminal is leaving garbage files in home directory

ups sorry for my misanderstanding

No problem, but for clarification: is $BASH_HISTORY injected into the shell once you've multiple tabs?

But I get the file dates: If testing with reboot results in Error:  the strange new upcoming files do have the (almost) same timestamp than the ~/.bash_history.

Not the timestamps *of* the files but *in* the files, bash can annotate when you issued that command and it would be required for any reasonable merge of multiple histories.

Not merged by timestamp.  The moment  a session is closed, the complete command-line history of the session is added to the ~/.bash_history.

That would require the combined history to be < HISTSIZE and also made the entire approach pointless.

If you've got an terminal open and you pull the plug you cannot expect that the session-command-line history is added to the ~/.bash_history.

Yes you can, see the bash manpage.

My tests shows: Under the condition: LXTerminal has some tabs open (= more than 1 session). If then I reboot the computer:  LXTerminal often does not add the session-history of all the (before open-)sessions

Ok, just to be sure: when you open an lxterminal with multiple tabs, issue some commands everywhere and then properly close that terminal, you do not get any stale history files?
How exactly do you reboot the computer? Do you push the power button or do you use some shutdown menu?

lxterminal should™ receive a sigterm for the latter which would allow it an orderly takedown.
Please post your complete system journal for the previous boot:

sudo journalctl -b -1 | curl -F 'file=@-' 0x0.st

after you caused it to leave some stale history files behind as well as

printenv

out of a couple of lxterminal tabs.

Online

#15 2025-07-15 08:20:59

Roberto2
Member
Registered: 2025-07-02
Posts: 9

Re: LXterminal is leaving garbage files in home directory

seth wrote:
Roberto2 wrote:

    If you've got an terminal open and you pull the plug you cannot expect that the session-command-line history is added to the ~/.bash_history.

Yes you can, see the bash manpage.

Sorry, I use the man page of GNU Bash 5.3, 2025 April 7, BASH(1)

...
When a shell with history enabled exits, bash copies the last $HISTSIZE entries from the history  list  to  $HISTFILE.
...

So, if you "pull the plug" (I mean: the computer is stopped and the still open terminal emulation might not have the chance to (graceful) exi)t: It can happen, that there will be _NO_ change of ~/.bash_history.

Offline

#16 2025-07-15 12:49:30

seth
Member
Registered: 2012-09-03
Posts: 65,914

Re: LXterminal is leaving garbage files in home directory

https://unix.stackexchange.com/question … al-windows

So, if you "pull the plug" (I mean: the computer is stopped

If you pull the power plug, the filesystem won't be sync'd and random stuff will have happened to your bash_history (and every other file you had opened and written to)

seth wrote:

Ok, just to be sure: when you open an lxterminal with multiple tabs, issue some commands everywhere and then properly close that terminal, you do not get any stale history files?

seth wrote:

How exactly do you reboot the computer? Do you push the power button or do you use some shutdown menu?

seth wrote:

lxterminal should™ receive a sigterm for the latter which would allow it an orderly takedown.
Please post your complete system journal for the previous boot:

sudo journalctl -b -1 | curl -F 'file=@-' 0x0.st

after you caused it to leave some stale history files behind as well as

printenv

out of a couple of lxterminal tabs.

Online

Board footer

Powered by FluxBB