Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am in my user's home directory, I do:

ls -a

Then it shows me large number of hidden files and directories in my user's directory. Which of them I am allowed to remove?

Which ones are necessary on my system?

How can I realize it?

share|improve this question

closed as unclear what you're asking by jasonwryan, slm, manatwork, Anthon, Zelda Mar 15 '14 at 13:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Why do you want to remove your .files? Each application you use will have a config file. vim might have .vimrc and .gvimrc and so. – clement Mar 15 '14 at 7:44
no some of them are stranges. like:rm .lesshst and .gout232342-1234 – MLSC Mar 15 '14 at 7:48
some are with no content and empty – MLSC Mar 15 '14 at 7:58
What would you save by removing empty files ? – jlliagre Mar 15 '14 at 7:58
You would be better off asking about specific files. You should not delete any dot (hidden) files unless you understand what they are for. – goldilocks Mar 15 '14 at 15:21
up vote 5 down vote accepted

As @mikeserv has already said, you are generally allowed to remove any files you want in your home directory. If you have sufficient privileges you can delete files in another user's home directory, but as we will see this may not be a very nice thing to in someone else's home directory. None of these files are necessary for your system to function, you at least have to become root to break the system.

However, the majority of these files contain settings or other data that the program uses when run as that user. Removing these may significantly change the way the program looks/feels for that user and may even cause data loss. Here are some of the things that I have in the hidden files/directories under home:

  • Settings for my desktop environment. If these get removed any customisations made to it, like walllpaper, screensaver, shortcut keys and taskbar/menu changes would all be restored to default next time the user logs in.

  • Web browser related data. Some of this will be bookmarks, browsing history etc which might be important. The bulk of the data will be the cache which contains downloaded web data (images etc). This would just be re-downloaded next time the page is visited, so generally no problem removing.

  • The .wine directory. This is the default location for the entire wine drive. If this removed, so would all software that the user has installed under wine!

  • The .cabal directory, this another example of a hidden directory where user software is stored. These are Haskell source packages installed by cabal.

  • Configuration files for various command line programs that I use, eg .bashrc, inputrc, .vimrc, .tmux.conf. Over the years many users will build up a substantial array of various settings/tweaks that help their workflow. I you removed mine that would be an incitement to violence! (well, not really, I would restore from a backup or just re-add stuff as I needed it).

Many programs will look for one or more of these files when it runs and it will create what it doesn't find. If it is a settings file, the newly created one will just have default settings. Any change made to the program's settings through its own interface will likely be stored in one of these. If cached data is removed, this will generally slow things down somewhere along the line as re-creating will take time (generally the reason for storing it in the first place).

Often it is difficult to find out what files belong to what program. The files will also not be removed when the program is uninstalled, so it is easy to collect ones that you don't need. If you want to remove some you could try to identify one that you don't need (eg if you remove a browser, the locating and removing its cache files could free up a lot of space). Either that or just identify what you want to keep and remove the rest - sometimes a clear out can be a good idea.

What may cause unexpected results is removing files like .bashrc and .profile, even if they have not been changed. The system will copy default versions of these files from /etc/skel when the user is created rather than them created by bash when it is run for the first time. If you accidentally delete one of these you can always restore it from /etc/skel (you can do ls -a /etc/skel to see what is there).

share|improve this answer
This is a really good answer, and it's definitely what I should have said. I'm just too much of a jerk, I guess. Thanks for not being one. – mikeserv Mar 15 '14 at 16:04
Thank you..good answer – MLSC Mar 16 '14 at 5:07
Congrats on getting to 5k. Great job keep up the solid answers! – slm Mar 24 '14 at 0:14
@slm, thanks again. – Graeme Mar 24 '14 at 11:54

If it's your $HOME directory, you're allowed to do whatever you want with it. In fact, that is the basic premise underlying all Unix filesystem permissions: ownership.

None of the files in your $HOME directory are necessary to the system. This is why they're in your $HOME directory and not elsewhere. That is the only clue you need.

The default file permissions (umask):

Each user has a default set of permissions which apply to all files created by that user, unless the software explicitly sets something else. This is often called the umask, after the command used to change it. It is either inherited from the login process, or set in the .cshrc or .login file which configures an individual account, or it can be run manually. Typically the default configuration is equivalent to typing umask 22 which produces permissions of:

  • -rw-r--r-- for regular files, or
  • drwxr-xr-x for directories.

In other words, user has full access, everyone else (group and other) has read access to files, lookup access to directories.

share|improve this answer

Which of them I am allowed to remove? Which ones are necessary on my system?

None, and all. Most of these files are created upon installation or when you run a program. Even if you delete them, they will come back.

How can I realize it?

Depending your use, but seriously, most of them use <1kB so it shouldn't bother you that they are there. Just don't type ls -a and you would never see them again.

share|improve this answer
Thank you, As you see the comments, I said I fear about some exploits or something like these...Some are binary files, All directories and files start with . in my home directory are safe you mean? – MLSC Mar 15 '14 at 12:08
Actually I have a total of 2.4 GB worth of hidden files in my home directory. This is significant even if a lot are less than 1 KB. – Graeme Mar 15 '14 at 12:17
@Graeme most likely those are Firefox/Flash/Chrome cache. I did find . -size +1M to search for all files over 1M and only found chromium, steam, skype, iceweasel, wine, related stuff. – Braiam Mar 15 '14 at 12:24
That's right, I have about 1 GB of wine related stuff and around 400 MB each for chromium and iceweasel. I also have a few hundred MB of cabal stuff. You can do GLOBIGNORE=.:..; du -ch .* | sort -h to get something like an ordered list. – Graeme Mar 15 '14 at 12:37
@MortezaLSC nothing in your home should be binary, do find . -type f -executable and look for clues. Anything that you don't know can be deleted. – Braiam Mar 15 '14 at 12:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.