Environment & Shell Customization (Aliases/Functions/.Bashrc)
Stop leaving your environment variables in the dark
đź§© The Challenge
You’re halfway through debugging a production service and realize your environment variables are completely different from what the service actually sees. It’s infuriating when you’ve got half a dozen shell windows open and you can’t remember which one has the correct credentials exported.
đź’ˇ The Fix
Build a simple function to print all your exported environment variables into a temporary file so you can diff them against another shell session. It saves you from guessing why one window is working and the other is throwing 403 errors.
function dumpenv {
export -p > ~/.last_session_env
echo "Environment exported to ~/.last_session_env"
}
⚙️ Why It Works
The export -p command prints all exported variables and functions in a format that’s ready to be re-sourced, which makes it perfect for comparing differences between sessions. Running this before you lose your mind over a missing key saves you an hour of head-scratching.
🚀 Pro-Tip: Keep a git-ignored file for your environment variables and source it in your bashrc so you don’t have to keep exporting them manually.
Linux Tips & Tricks | © ngelinux.com | 7/22/2026
