1

How can one prevent .ash_history from being saved at all in Alpine Linux?

2 Answers 2

3

Try

unset HISTFILE

To make the change permanent, add it to your profile. It should be /etc/profile or ~/.profile

1
  • This no longer works, see my answer for alternatives and explanation.
    – tom
    Nov 27, 2023 at 17:24
0

Add the following line to ~/.profile (or /etc/profile to disable history for all users):

export HISTFILE=/dev/null

Alternatively, run the following command:

rm ~/.ash_history; ln -s /dev/null ~/.ash_history

(This replaces ~/.ash_history with a symlink pointing to /dev/null, so that writes to ~/.ash_history will be discarded. To re-enable history, remove ~/.ash_history.)


Note that unset HISTFILE (which is commonly used with bash) doesn't work for two reasons:

  • Since Busybox 1.22 (released January 2014; commit), ash sources ~/.profile before it sets HISTFILE, to allow ~/.profile to change HOME. An unfortunate side effect is that unsetting HISTFILE in ~/.profile has no effect.

  • Even before that, it only worked when ash was invoked as a login shell, because non-login shells (e.g. those started by running ash or by GNU screen) don't source ~/.profile so they would save history. (The first command I suggest uses export to ensure that all child processes will inherit the setting.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .