Has cleared command history by running the PowerShell command Remove-Item (Get-PSReadlineOption).HistorySavePath.1
- Tactic
- Stealth
- Platforms
- ESXi, Linux, macOS, Network Devices, Windows
- Version
- 2.0
- Created
- 31 January 2020
- Last modified
- 12 May 2026
- Contributors
- Vikas Singh, Sophos; Emile Kenning, Sophos; Austin Clark, @c2defense
In addition to clearing system logs, an adversary may clear the command history of a compromised account to conceal the actions undertaken during an intrusion. Various command interpreters keep track of the commands users type in their terminal so that users can retrace what they've done.
Clear Command History MITRE reference T1070.003
8 groups have been recorded using this technique. Newest first; each entry carries MITRE’s procedure text and a link to the group’s full record. Click a name to filter the rules below.
Has cleared the command history on targeted ESXi servers.1
Cleared command history in Linux environments to remove traces of activity after operations.1
Attempted to remove evidence of some of its activity by deleting Bash histories.1
Has removed mailbox export requests from compromised Exchange servers.1
All 8 groups for this technique · 6 newest in this preview
3 software entries are documented implementing this technique. MITRE files each as a tool or as malware; newest first, then by how many groups carry them.
Can overwrite previously executed command line arguments.1
Can remove all command history on compromised hosts.1
Has used history -c to clear script shell logs.1
All 3 software entries for this technique
Offense vs defense T1070.003
Is defensive coverage keeping up with adversary use? Eight counts, each ranked against all 697 ATT&CK techniques. Attack sits left, defense right, so a shape leaning left means adversaries are better documented here than defenders are equipped. Hover any spoke for its percentile and the share of techniques that have more. The timeline below shows when each side arrived.
How it got here
Adversary activity (campaign spans) over cumulative rule output. Each source is plotted independently from zero, so neither line includes the other. Campaign dates are year-granularity.
Clear Command History detection strategy DET0165
MITRE names one behaviour worth catching for this technique and breaks it into 5 analytics, one per platform. Each carries the log sources it needs and the fields you tune per environment.
Behavioral Detection of Command History Clearing
AN0467 · Linux
Detects adversary behavior clearing command history via history -c, deletion or modification of ~/.bash_history, or manipulation of the HISTFILE environment variable post-login.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | auditd:SYSCALL | execve |
| File DeletionDC0040 | auditd:SYSCALL | PATH |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| TimeWindow | Detect shell history clearing shortly after login or command execution. |
| UserContext | Elevated shell sessions (e.g., root or sudo) without command history may be more suspicious. |
| HistoryFilePath | Bash/Zsh history file paths (e.g., ~/.bash_history, ~/.zsh_history). |
AN0468 · macOS
Detects adversary clearing shell history using history -c or deleting/altering ~/.zsh_history or ~/.bash_history. Focus on sessions with missing or wiped history.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | macos:unifiedlog | process |
| File ModificationDC0061 | fs:fsusage | unlink, write |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| TimeWindow | Duration after terminal usage where deletion or modification is considered suspicious. |
| UserContext | Flag unexpected user activity, especially from users who normally don’t use terminal. |
| HistoryFilePath | Zsh or Bash history files under the user's home directory. |
AN0469 · Windows
Detects PowerShell Clear-History invocation or deletion of ConsoleHost_history.txt to erase past PowerShell session history.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| File DeletionDC0040 | WinEventLog:Sysmon | EventCode=23 |
| File ModificationDC0061 | WinEventLog:Security | EventCode=4663, 4670, 4656 |
| Command ExecutionDC0064 | WinEventLog:PowerShell | EventCode=4103, 4104, 4105, 4106 |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| HistoryFilePath | Path to PSReadLine file, typically in APPDATA. |
| UserContext | User account or role performing deletion (e.g., low-priv user deleting history). |
| CommandPattern | Support detection of Clear-History and variations. |
AN0470 · ESXi
Detects modification or truncation of /var/log/shell.log used to persist ESXi shell command history. Especially suspicious shortly after login or config changes.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| File DeletionDC0040 | esxi:shell | /var/log/shell.log |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| LogFilePath | Path to shell command history on ESXi. |
| TimeWindow | Time range post-login or privileged escalation. |
AN0471 · Network Devices
Detects use of clear history or clear logging commands on network device CLI to remove past activity logs.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Command ExecutionDC0064 | networkdevice:syslog | CLI command audit |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| CommandPattern | Support detection of known variants: 'clear history', 'clear logging', etc. |
| DeviceType | Router, switch, firewall—may have different CLI behaviors. |
Adversaries may attempt to conceal their tracks by deleting the history of commands run within the Powershell console, or turning off history saving to begin with. This analytic looks for several commands that would do this. This does not capture the event if it is done within the console itself; only commandline-based commands are detected. Note that the command to remove the history file directly may very a bit if the history file is not saved in the default path on a particular system.
D3FEND techniques
The defensive countermeasure this analytic implements, in MITRE’s D3FEND ontology.
| ID | Name |
|---|---|
| D3-PSA | Process Spawn Analysis |
Data model references
The CAR data model objects, actions and fields the logic reads. Map these to your own schema before implementing.
| Object | Action | Field |
|---|---|---|
| process | create | exe |
| process | create | command_line |
Implementations
Pseudocode is the canonical logic; the rest are CAR’s translations into vendor query languages.
This is a pseudocode representation of the below splunk search.
processes = search Process:Create clear_commands = filter processes where ( command_line ="*rm (Get-PSReadlineOption).HistorySavePath*" OR command_line="*del (Get-PSReadlineOption).HistorySavePath*" OR command_line="*Set-PSReadlineOption –HistorySaveStyle SaveNothing*" OR command_line="*Remove-Item (Get-PSReadlineOption).HistorySavePath*") OR command_linee="del*Microsoft\Windows\Powershell\PSReadline\ConsoleHost_history.txt") output clear_commands
Look for powershell commands that would clear command history
(index=__your_sysmon_index__ EventCode=1) (CommandLine="*rm (Get-PSReadlineOption).HistorySavePath*" OR CommandLine="*del (Get-PSReadlineOption).HistorySavePath*" OR CommandLine="*Set-PSReadlineOption –HistorySaveStyle SaveNothing*" OR CommandLine="*Remove-Item (Get-PSReadlineOption).HistorySavePath*" OR CommandLine="del*Microsoft\\Windows\\Powershell\\PSReadline\\ConsoleHost_history.txt")
Look for powershell commands that would clear command history
norm_id=WindowsSysmon event_id=1 (command="*rm (Get-PSReadlineOption).HistorySavePath*" OR command="*del (Get-PSReadlineOption).HistorySavePath*" OR command="*Set-PSReadlineOption –HistorySaveStyle SaveNothing*" OR command="*Remove-Item (Get-PSReadlineOption).HistorySavePath*" OR command="del*Microsoft\Windows\Powershell\PSReadline\ConsoleHost_history.txt")
Making the environment variables associated with command history read only may ensure that the history is preserved.
Forward logging of historical data to remote data store and centralized logging solution to preserve historical command line log data.
Preventing users from deleting or writing to certain files can stop adversaries from maliciously altering their ~/.bash_history or ConsoleHost_history.txt files.
Tests from Atomic Red Team (MIT licence) · technique definition