Is it safe to delete every hidden folder in the home directory?
My $HOME (otherwise known as '~') directory has lots of hidden configuration folders.
Is it safe to delete all of them?
To be specific
- Will the OS break if I do so?
- Will my ethernet/printer/sound/graphics drivers stop working?
- I don't care about superficial things like: Gnome themes, Key shortcuts, Font settings, etc
You should be relatively safe:
- Surely your OS won't break, dot files in
home
directory are mostly configuration files, if they're not there any app will just use the defaults. - Device drivers (as ethernet,video,sound,...) should be configured systemwide, so you should be safe.
- Those are the things will "break" as all your preferences/customizations will get lost, but you don't care ;)
In fact if you add another user to the system his home directory will be mostly empty, apart from some default files which are put inside by default. But those defaults are distro-specific and surely not mandatory.
So yes, you should be quite safe deleting everything under home
.
Just in case, play safe and move them to another directory and check everything is ok before deleting them.
It is NOT safe to delete them. I want to give you an idea why so I did a quick check on my home folder and here are a some reasons why for me it would not be safe (And make me cry a river really):
They contain configuration files. It is known that some of them can recreate themselves but if you changed or customized an application, the change will be gone.
For the .local and .cache folder, you are talking about multiple configuration and downloaded cache packages. This involves having to download several megabytes if not gigabytes of information again or having to reinstall some apps again (if they manage to give an error about not reading the configuration file)
For very big apps like WINE which happens to hide itself in .wine in the home folder, killing it, well, that is like formatting your whole windows drive. You have just removed everything about wine and any windows app you happened to install. In my case we are talking about 6 apps that come to 23GB of information. Imagine if somebody installed 10 games, microsoft office, photoshop and some other apps and then deleted all of that. Heart attack approaching.
If you have the XBMC folder in there which is .xbmc. I know several people including me will cry over the fact that they have to download ALL the content again for the movies and video series. That is about 12 hours worth of work assuming the internet connection does not drop.
The .mozilla folder is there. Your configuration and addon information will be lost.
Do you use several SSH sites. Well not anymore. You need to configure them again. This could be read as a security problem if you do this on a company.
Were you pimping you gimp with better addons. Not anymore, the config got deleted.
Did yo happen to have a personalized Terminal window (like the bash and profile hidden files). Nope, you did not, since your configuration file got deleted.
Not all hidden elements are folder. There are several hidden file that are used very often like the bash and profile files, the history file and logs.
And to top it off, apart from the obvious Reboot you have to do, there is not 100% way to be sure that everything will come back working correctly. Maybe for a just installed system, but for somebody that for example has had those hidden folders and files since 4 Ubuntu versions ago, one problem can become big very quickly.
Now for you question, will drivers stop working. No they will not. they will still work after cleaning up.
Will the OS break. It depends. If a running service has a configuration in there, you might get a problem there. If a RC customized file has a file in there, you will have a problem. For a common user that just installed the system, there will be no problem at all, but give it a year with several programs installed and customized stuff. you might regret having to delete all of that.
The short answer is yes, it can be dangerous and it will have detrimental effect on your use of the system, even if the system itself won't be affected. That is to say, other users will continue as if nothing had happened, even if your user account will be useless.
Some of the dotfiles are created when the user account is first created, meaning that it will not be recreated automatically. Lots and lots of applications depend on them, meaning that those applications will not work properly. Many applications are totally dependent on configurations. If they aren't available and cannot be created, then the application will be useless and may crash or refuse to run.
It would be similar to deleting the registry in Windows, but worse since dotfiles in Ubuntu not only holds configuration, but also holds personal data. Your databases are stored in ~/.local/share/desktop-couch/ for instance. If you are synced with Ubuntu One, then deleting that folder might also delete those databases from all other computers, including the web.
If you had provided more details about why you would want to do this, then it would be easier to give an exact answer. But if for some reason you really do want to do this, then I think this is the way you should do it: (please be sure you want to)
Only perform these steps if your home directory is not encrypted.
- Create a temporary user named "tempuser" for instance.
- Add that user to the admin group just in case.
- Log out of all desktop sessions
- Switch to another console by pressing alt+ctrl+f1
- Log in with the temporary user
- Rename your old home directory (something like mv /home/bob /home/bob.bak)
- Create a new home directory for yourself
- Set the right permissions on it.
Now you have a clean system for your user, just as when you logged in for the first time. You can start to copy files from the old home directory into the new one. Don't "cut" or move. That way you'll have the old home directory as backup if something goes wrong. Please pay attention to what you're doing. If you're logged into Ubuntu One, for instance and you replace the files that contain information about synchronized files and folders, then Ubuntu One will notice that those files are no longer available. To it, that means you have deleted them and it will synchronize those deletions across your network, meaning it will delete all those files from all your computers and on the web. So make sure you know what every file is and what every file does. And in any case, do make a backup. There are good chances you will do something you didn't intend to do, or that something you intended to do had side-effects you didn't know about.
In summary:
- Make sure your reasons are valid
- Take a backup first (I'm not joking)
- Pay close attention to what you're doing
- Write down everything you do so you can learn from your potential mistakes.
I've just tested it and removed everything in my /home/test
directory. I was then able to login through terminal (Ctrl+Alt+F1) and graphically too.
Why would you want to do that is another question. If you want to remove a user account, do it from Users and Groups or similar settings manager.