Lesson 6.3: Shell start-up files
Which files bash reads when it starts (/etc/profile, ~/.profile, ~/.bashrc), what belongs in each, aliases, making changes permanent, reloading with source, and why attackers like these files.
14 min
You will learn to
- Name the start-up files and when each is read
- Create and remove aliases
- Make a PATH change and an alias permanent in ~/.bashrc
- Reload settings with source
- Explain why start-up files are a persistence target
Key terms
- /etc/profile and /etc/bash.bashrc
- System-wide start-up files for every user, edited by the administrator.
- ~/.profile
- Read by login shells (when you log in, over SSH or a text console). The place for environment variables such as PATH.
- ~/.bashrc
- Read by every interactive bash that isn't a login shell, e.g. each new terminal window. The place for aliases, prompt and history settings.
- Alias
- A short name the shell replaces with a longer command before running it.
- source (.)
- Runs a file's commands in the current shell, so its variables and aliases stay. Running the file as a script would apply them to a child shell that exits immediately.
- Persistence
- In security, any way an attacker makes their access survive reboots and logouts. Start-up files, cron jobs and services are classic places.
← Environment variables · All lessons · Redirecting input and output →