Записи в истории

Я обычно включаю пароль, когда я вхожу в систему MySQL. Как я исключаю mysql -u root -pPassword будучи взятым и сохраненный историей?

2
задан 22 June 2015 в 13:25

1 ответ

Поместите пространство перед своей командой.

Это будет работать потому что, по умолчанию, переменная $HISTCONTROL содержит ignoreboth что означает ignorespace и ignoredups; ignorespace то, что заставляет удар не сохранить команду в истории, когда существует ведущее пространство.

От man 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  current 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.

Если Вы хотите исключить определенную команду из истории Bash в масштабе всей системы, добавьте следующее к Вашему /etc/bash.bashrc:

HISTIGNORE='mysql*'

Это исключит любую команду, которая запускается с mysql.

Выполниться source /etc/bash.bashrc применять изменения.

Источник: https://unix.stackexchange.com/questions/32460/excluding-some-of-the-commands-from-being-getting-stored-in-bash-history

2
ответ дан 2 December 2019 в 03:59

Другие вопросы по тегам:

Похожие вопросы: