Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

The .viminfo file in my home directory is owned by root. Could anyone please explain how that could have happened without me asking it?

$ ls -la | grep .viminfo
-rw-------  1 root    root       4175 Nov  3 19:11 .viminfo
share|improve this question
up vote 3 down vote accepted

I think it was created while using "sudo vim" to edit some file on the system.

share|improve this answer
sudo -s or -u retain the shell environment, i.e. the users home directory when using sudo thus vim thinks it is supposed to be so. – con-f-use Nov 3 '12 at 12:54
After digging a bit I found that .viminfo is created when you run vim for the first time. I ran 'sudo vim' to edit /etc/apt/sources.list file. Since 'sudo' keeps $HOME variable, .viminfo was created in my home directory with root as the owner. – user1357768 Nov 3 '12 at 14:16

This could happen if you run vim after sudo -s

You can chown it back to your id:group anyway, does't hurt;-)

share|improve this answer
Isn't this a bug? – becko Dec 9 '15 at 20:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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