Skip to content

Instantly share code, notes, and snippets.

@aw-junaid
Created January 30, 2026 17:36
Show Gist options
  • Select an option

  • Save aw-junaid/4259c963aaf68886af8ca235850f377f to your computer and use it in GitHub Desktop.

Select an option

Save aw-junaid/4259c963aaf68886af8ca235850f377f to your computer and use it in GitHub Desktop.
Commands to clear or disable Bash history, stop logging to history files, truncate auth logs, terminate the current shell, and redirect history output to /dev/null. Includes corrected syntax and a few related essentials for controlling traces and sessions.

Controller Commands: History, Logs, and Session Control

Commands to clear or disable Bash history, stop logging to history files, truncate auth logs, terminate the current shell, and redirect history output to /dev/null. Includes corrected syntax and a few related essentials for controlling traces and sessions.


Log file control

  • : > /var/log/auth.log

    Truncates /var/log/auth.log to zero bytes (clears contents without deleting the file).
    (echo "" /var/log/auth.log corrected; that would only print to stdout unless redirected.)

  • echo "" > /var/log/auth.log

    Overwrites the log with a single blank line (also effectively clears). Requires root.


Bash history control (current session + history file)

  • echo '' > ~/.bash_history

    Overwrites the current user’s history file with empty content (clears saved history file).
    (Your echo '''' -/.bash history corrected to a working path and redirection.)

  • rm -rf ~/.bash_history

    Deletes the user’s .bash_history file.
    (Your rm -/.bash history/ -rf corrected.)

  • history -c

    Clears the in-memory history list for the current shell session.

  • export HISTFILESIZE=0

    Sets maximum number of lines stored in the history file to 0 (prevents writing history lines to file in many setups).

  • export HISTSIZE=0

    Sets maximum number of commands kept in memory history to 0 (limits/blocks session history).

  • unset HISTFILE

    Unsets the variable that points to the history file; the shell won’t write history to a file. Often takes effect fully after starting a new shell/login.


Session control

  • kill -9 $$
    Immediately kills the current shell process ($$ is current shell PID). This terminates your current session.
    (Your “Delete the current meeting” interpreted as ending the current session.)

Permanently redirect history to /dev/null

  • ln -sf /dev/null ~/.bash_history
    Replaces ~/.bash_history with a symlink to /dev/null, so attempts to write history are discarded.
    (Your ln /dev/null -/.bash_historj -sf corrected.)

Important additions for controller/history behavior

  • history -w

    Forces the current session history to be written to the history file (useful to know because it can re-populate the file if you cleared it but didn’t stop writes).

  • history -a

    Appends session history to the history file (commonly used in multi-terminal setups).

  • history -r

    Reloads history file into the current shell (can bring back lines you thought were gone).

  • export HISTCONTROL=ignorespace

    Commands starting with a leading space are not saved to history (if the shell is configured to honor this).

  • export HISTCONTROL=ignoreboth

    Ignores duplicate commands and commands starting with a space.

  • export HISTTIMEFORMAT=""

    Removes timestamps from history output (if previously enabled).

  • : > ~/.bash_history && history -c

    Common pair: clears the on-disk history file and the in-memory history list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment