-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Luis Miguel P. Freitas edited this page Feb 24, 2025
·
3 revisions
A utility script to safely reset bash profile configuration files to Debian 12 defaults while creating automatic backups.
- Automatically backs up existing bash configuration files
- Restores default Debian bash profile settings
- Sets correct file permissions
- Creates timestamped backups
- Provides clear feedback and error handling
- Validates user input and permissions
- Debian 12 Linux distribution
- Root access (sudo privileges)
- Bash shell
- wget
- 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.shRun the script with sudo, providing the target username:
sudo ./reset-bash-profile.sh usernameExample:
sudo ./reset-bash-profile.sh johndoe- Creates a timestamped backup directory in the user home folder
- Backs up existing
.bashrc,.profile, and.bash_logoutfiles - Copies default configuration files from
/etc/skel/ - Sets appropriate ownership and permissions
- Provides instructions for applying changes
- Backup files:
~/bash_backup_YYYYMMDD_HHMMSS/ - Default configuration source:
/etc/skel/ - Target files:
~/.bashrc~/.profile~/.bash_logout
The user should either:
- Log out and log back in OR
- Run the following command to apply changes immediately:
source ~/.bashrcIf you had custom modifications in your bash profile:
- Check the backup directory (
~/bash_backup_YYYYMMDD_HHMMSS/) - Compare the backed-up files with the new ones
- Manually restore any desired customizations
-
"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/
Feel free to submit issues and enhancement requests to luis@digitalxs.ca!
This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 3 - see the LICENSE file for details.
Luis Miguel P. Freitas - 2025
- Based on Debian default bash configuration
- Inspired by the need for a safe way to reset bash profiles after customizations that went wrong.
- 1.0.2 (2024-02-23)
- Some corrections and bugfixes
- Basic functionality for resetting bash profile
- Automatic backups with timestamps
- Changed curl to wget