In case you made changes to .bashrc and bash profiles and something went wrong, you may want to revert / reset / restore to the default bash profile. Here's how to restore these to Debian 12 defaults:
Contents
Backup Existing Files
First, create a backup of your current configuration files:
cd /home/[user] mkdir bash_backup cp .bashrc .profile .bash_logout bash_backup/
Copy Default Files
Copy the default configuration files from /etc/skel/. This directory contains the default files that Debian uses when creating new users:
cp /etc/skel/.bashrc /home/[user]/ cp /etc/skel/.profile /home/[user]/ cp /etc/skel/.bash_logout /home/[user]/
Set Permissions
Set the correct ownership and permissions for the configuration files:
chown [user]:[user] /home/[user]/.bashrc chown [user]:[user] /home/[user]/.profile chown [user]:[user] /home/[user]/.bash_logout chmod 644 /home/[user]/.bashrc chmod 644 /home/[user]/.profile chmod 644 /home/[user]/.bash_logout
Apply Changes
To apply the changes, either: Log out and log back in, or source the new .bashrc file directly:
source ~/.bashrc
If you've made any custom modifications to your PATH or other environment variables in these files, you'll need to add them back manually after reviewing your backup files.
Important Note
From DebianSqueeze to DebianBullseye, it is possible to select Bash as the target of the /bin/sh symlink by running dpkg-reconfigure dash. However, as of DebianBookworm, this is no longer supported.
Optional: Automate Bash Profile to restore bash defaults
This script is just to automatize what is explained previously on this article, and the code should be reviewed before usage.
Debian 12 Utility Script is published at : https://github.com/digitalxs/BashProfileReset
This a Debian 12 Utility Script to revert a bash profile on Debian 12 to defaults and recreates all the steps described above but also checks for errors and creates backup of the previous bash profile and sets proper permissions of files related to the bash profile automatically.
Links
Bash Project Official Page: https://www.gnu.org/software/bash/
Bash Manual: https://www.gnu.org/software/bash/manual/
Bash Maintainer: https://tiswww.case.edu/php/chet/bash/bashtop.html
Bash Development: https://savannah.gnu.org/projects/bash/
BashProfileReset Debian 12 Utility Script: https://github.com/digitalxs\BashProfileReset - Utility script to revert bash profile on Debian 12 to defaults.