This simple tutorial shows how to reset user’s default hidden files, including ‘.profile’, ‘.bashrc’, ‘.bash_profile’, ‘.bash_login’, etc, in Debian, Ubuntu, Fedora, and other Linux.
Each user has a few hidden files, that are created automatically, when adding the user account.
They include .bashrc
, a script that run automatically at login. Without it, your terminal or command console will lose colors, ‘Tab’ key auto-completion will refuse to work, bash history and alias commands may also no longer work.
Another file is .profile
or .bash_profile
, .bash_login
depends on your Linux system. Which is used to configure user’s $PATH variable. Most apps are installed to system $PATH, so you can run them without typing full path to executable file. For example, your may run firefox
instead of /usr/bin/firefox
to launch web browser, because it’s installed in your $PATH. If you accidentally remove or break the .profile
file, then apps installed to .local/bin
, $HOME/bin
, or other custom $PATH directories will not work properly.
Reset .profile, .bashrc etc files
Most Linux has a copy of these default user files, available in /etc/skel
. Every time when creating a new user account, it automatically copies these files into user’s home directories.
So, to reset these user files, just do copy and paste again from the /etc/skel
to your user home!
To do so, first launch terminal either from start/application menu or ‘Activities’ overview depends on your desktop environment.
Then, run command to copy the hidden files to user home:
sudo cp -rT /etc/skel ~/
NOTE: This command will reset all the default user files. In some Linux (e.g., Manjaro), it even reset user defined app shortcuts and auto-start applications.
To be safe, run this command (with ‘-n’ option) instead:
sudo cp -rTn /etc/skel ~/
Which only copy the missing files to user home, while leaving all existing files un-changed.
Or, you may run sudo cp /etc/skel/.file_name ~/
(replace file_name
) to reset a certain file to factory state.
After that, you need to run one more command:
sudo chown -R $USER:$USER ~/
Which will change the ownership for all the files in user home to yours!
When done, log out and back in to take place.
Summary
In short, the /etc/skel
keeps a copy of user default files. Copy them back to user’s home, and change the ownership will reset them to factory state.