A robust utility script to safely reset bash profile configuration files to Debian 12 defaults
with automatic backups, restoration capabilities, and advanced user controls.
# Download the script
wget -v https://github.com/digitalxs/BashProfileReset/raw/refs/heads/main/reset-bash-profile.sh
# Make it executable
chmod +x reset-bash-profile.sh
# Run it (replace 'username' with the target user)
sudo ./reset-bash-profile.sh username- Automatic timestamped backups of all bash configuration files
- Customizable backup locations
- Backup metadata tracking
- Preservation of file attributes and permissions
- Dry-run mode to preview changes without applying them
- Force mode to skip confirmation prompts
- Verbose mode for detailed operation logging
- Custom backup location specification
- List all available backups for a user
- Restore from any previous backup
- Safe restoration process with confirmations
- Proper permission settings on all files
- Secure backup directories (700 permissions)
- Detailed operation logging
- Color-coded output for better readability
- Clear operation summaries
- Helpful next-step guidance
- Command-line help system
-
Download the script:
wget -v https://github.com/digitalxs/BashProfileReset/raw/refs/heads/main/reset-bash-profile.sh
-
Make the script executable:
chmod +x reset-bash-profile.sh
-
Verify installation:
./reset-bash-profile.sh --version
Reset a user's bash profile to defaults on Debian 12:
sudo ./reset-bash-profile.sh usernamesudo ./reset-bash-profile.sh --helpsudo ./reset-bash-profile.sh username --dry-runsudo ./reset-bash-profile.sh username --forcesudo ./reset-bash-profile.sh username --backup-dir /var/backups/bashsudo ./reset-bash-profile.sh username --list-backupssudo ./reset-bash-profile.sh username --restore /home/username/bash_backup_20240327_123456sudo ./reset-bash-profile.sh username --verbose --backup-dir /backups --force- Checks for root privileges
- Validates the username exists
- Verifies the home directory is accessible
- Creates a timestamped backup directory
- Backs up all bash-related configuration files
- Creates metadata about the backup
- Sets secure permissions on the backup
- Removes existing bash configuration files
- Copies default files from
/etc/skel/ - Sets appropriate ownership and permissions
- Provides a summary of operations performed
- Shows the backup location
- Gives instructions for applying changes
~/.bashrc- Main bash configuration file~/.profile- Login shell configuration~/.bash_logout- Commands executed when logging out
~/.bash_aliases- Custom command aliases~/.bash_functions- User-defined bash functions~/.bash_history- Command history~/.bashrc_help- Custom help files~/.inputrc- Readline configuration~/.config/starship.toml- Starship prompt configuration
-
"Error: Please run as root"
- Solution: Run the script with sudo
-
"Error: User 'username' does not exist"
- Solution: Check if the username is correct
- Verify the user exists on the system
-
"Warning: Could not backup/copy file"
- Solution: Check file permissions
- Verify the source files exist in
/etc/skel/
-
"Error: Backup directory does not exist"
- Solution: Verify the path provided to
--restoreis correct - Use
--list-backupsto see available backups
- Solution: Verify the path provided to
-
Run with verbose mode to see detailed operation logs:
sudo ./reset-bash-profile.sh username --verbose
-
Use dry-run mode to test operations without making changes:
sudo ./reset-bash-profile.sh username --dry-run
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- You can use, modify, and distribute this software.
- If you distribute modified versions, you must make your source code available.
- Changes must be documented.
- The same license applies to derived works.
- Original Author: Luis Miguel P. Freitas
- Website: DigitalXS.ca
- Email: luis@digitalxs.ca
If you find this script useful, consider buying me a coffee! Your support helps maintain this project and develop new features.

