有没有办法打开“隐身”终端/外壳?

Dmi*_*yov 7 terminal shell

在正常情况下,在终端/shell 中键入的命令可以稍后通过历史命令或其他方式检索。

有没有办法拥有一个“隐身”终端/外壳,即在关闭后不会以任何方式记住其命令的终端/外壳?

一种用途是向信用卡收费,或执行其他安全敏感命令。

一个可能的答案是启动 Linux “Live CD”,然后将其关闭。任何其他(更简单的)方法可以在 OS X/Linux/Windows 中工作?

Mat*_*teo 7

您没有指定您使用的是哪个 shell,但是:

HISTFILE环境变量定义了历史记录存储。和

unset HISTFILE
Run Code Online (Sandbox Code Playgroud)

您可以告诉 bash 停止记录命令。您可以重新启用它

export HISTFILE=${HOME}/.bash_history
Run Code Online (Sandbox Code Playgroud)

来自man bash

HISTFILE
       The name of the file in which command history is saved (see  HISTORY  below).   The  default
       value  is  ~/.bash_history.   If unset, the command history is not saved when an interactive
       shell exits.
Run Code Online (Sandbox Code Playgroud)

  • @Matteo 这似乎并不完全正确。在 Mac OSX 的终端中,如果我这样做:`unset HISTFILE; sudo echosensitive_command`,然后`sudo grep -r "[s]ensitive_command" /` ...我可以在`/private/var/log/system.log`中看到该命令。 (2认同)
  • 经过一些测试,似乎只有成功的 sudo 命令才会登录到 `/private/var/log/system.log`(仅限 sudo 命令,即使是 root 用户)。 (2认同)