Control which files bash reads at login to make environment, PATH and aliases persistent. 14.12.2025 | reading time: 2 min Wonder which files bash reads when you log in and how to make PATH and aliases persistent? Learn to edit the right dotfiles and run a quick test to see results immediately. Make PATH and Prompt Persistent Create a minimal login setup and test it with these commands: ```\ncat > ~/.bash_profile <<'EOF'\nif [ -f ~/.bashrc ]; then\n . ~/.bashrc\nfi\nexport PATH=\"$HOME/bin:$PATH\"\nEOF\n\ncat >> ~/.bashrc <<'EOF'\nalias ll='ls -la'\nPS1='my-shell$ '\nEOF\n\nsource ~/.bash_profile\necho $PATH\n# => /home/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin\ntype ll\n# => ll is aliased to 'ls -la'\n``` Login Versus Interactive Bash reads startup files in a specific order for a login shell: first `/etc/profile`, then the first existing file among `~/.bash_profile`, `~/.bash_login`, and `~/.profile`; an interactive non-login shell reads `~/.bashrc` so it is common to source `~/.bashrc` from `~/.bash_profile`; to simulate a login shell run `bash --login -i` and observe which files are executed. System-wide and Security Notes System-wide files such as `/etc/profile` and `/etc/bash.bashrc` set defaults for every user, so edit them only as root and avoid putting secrets in readable dotfiles; ensure dotfiles are owned by the user and not world-writable to prevent privilege escalation or accidental exposure. Practical Variations Use `~/.bash_login` for legacy behavior when you need compatibility with sh-style profiles, export variables like `EDITOR` and `LANG` in login scripts, and prefer `~/.bashrc` for aliases and functions that should run in each interactive shell. Where to Go Next Mastering these small files rapidly improves daily efficiency; learn more about shell behavior, scripting and system administration and consider certifications like CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. scripting boot-process setup utilities