T1546.004
Unix Shell Configuration Modification
Adversaries may establish persistence through executing malicious commands triggered by a user's shell. User Unix shells execute several configuration scripts whenever a shell session is opened. Malicious content can be inserted into these shell configuration files — such as ~/.bashrc, ~/.bash_profile, ~/.bash_login, ~/.profile, /etc/profile, /etc/bashrc, ~/.zshrc, and ~/.zprofile — to execute adversary payloads when a user opens a terminal or logs in. The payload will execute in the user's context each time the shell is started.
Microsoft Sentinel / Defender
kusto
let ShellConfigPaths = dynamic([
".bashrc", ".bash_profile", ".bash_login", ".profile",
".zshrc", ".zprofile", ".zshenv", ".zlogin",
".tcshrc", ".cshrc",
"profile", "bashrc", "bash.bashrc",
".config/fish/config.fish"
]);
DeviceFileEvents
| where Timestamp > ago(24h)
| where FileName has_any (ShellConfigPaths)
or FolderPath has_any ("/etc/profile.d/", "/etc/bash_completion.d/")
| where ActionType in ("FileCreated", "FileModified")
| extend IsEtcFile = FolderPath startswith "/etc/"
| extend IsUserProfile = FolderPath has_any ("/home/", "/root/", "Users")
| project Timestamp, DeviceName, AccountName, ActionType, FileName, FolderPath,
IsEtcFile, IsUserProfile,
InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc medium severity
medium confidence
Data Sources
File: File Creation File: File Modification Microsoft Defender for Endpoint
Required Tables
DeviceFileEvents
False Positives
- Package managers (apt, yum, dnf, brew) that modify /etc/profile.d/ or /etc/bashrc when installing packages that add environment variables or aliases
- Configuration management tools (Ansible, Chef, Puppet, Salt) that manage shell configuration files as part of system baseline enforcement
- Users legitimately modifying their own .bashrc or .zshrc to add aliases, set PATH, or configure their prompt
- Developer toolchains (rbenv, pyenv, nvm, sdkman) that append initialization code to shell config files during installation
Last updated: 2026-04-20 Research depth: deep
Unlock Pro Content
Get the full detection package for T1546.004 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance
Related Detections
Parent Technique
T1546Event Triggered ExecutionRelated Sub-techniques
T1546.001Change Default File AssociationT1546.002ScreensaverT1546.003Windows Management Instrumentation Event SubscriptionT1546.005TrapT1546.006LC_LOAD_DYLIB AdditionT1546.007Netsh Helper DLLT1546.008Accessibility FeaturesT1546.009AppCert DLLsT1546.010AppInit DLLsT1546.011Application ShimmingT1546.012Image File Execution Options InjectionT1546.013PowerShell ProfileT1546.014EmondT1546.015Component Object Model HijackingT1546.016Installer PackagesT1546.017Udev RulesT1546.018Python Startup Hooks