Respuestas:
Agregue espacio antes del comando. Los comandos que comienzan con un espacio no se colocan en el historial:
root@ubuntu-1010-server-01:~# echo foo
foo
root@ubuntu-1010-server-01:~# history
1 echo foo
2 history
root@ubuntu-1010-server-01:~# echo bar
bar
root@ubuntu-1010-server-01:~# history
1 echo foo
2 history
hombre bash
HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines matching the cur‐ rent line to be removed from the history list before that line is saved. Any value not in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of HISTCONTROL.
/etc/profilecomo HISTCONTROL=ignorebothy exporto la variable HISTCONTROL.
También vale la pena mencionar el truco para matar la sesión de inicio de sesión actual en lugar de la salida normal (por lo tanto, no da la oportunidad de guardar el historial). Esto es especialmente útil cuando inicia sesión en un a / c compartido, en lugar de recordar prefijar con un espacio, simplemente puede finalizar la sesión eliminándola. La forma más sencilla de matar es ejecutando este comando:
kill -9 0
Pid 0 siempre se refiere al PID del proceso actual, por lo que básicamente se envía una señal de muerte mortal a sí mismo. También uso esto a menudo en lugar de salir normalmente, ya que a menudo tengo sesiones bloqueadas en la salida normal, probablemente debido a alguna configuración incorrecta.