2

I found a file called kernel-4.2.5 in my Home directory and I want to delete it but I don't know what harm that could cause. Is there a way of knowing if that file is being used because my kernel version is 4.4.0-31-generic.

In addition, how do I find out all the installed programs on my system that I no longer use?

Mr. T
  • 153
  • 1
  • 9
  • How do you define an installed program that you no longer use? – Byte Commander Jul 17 '16 at 13:53
  • Maybe not used in the last month or probably one that didn't install correctly. I'd prefer to see all the programs I've ever installed and make a choice of what to uninstall. – Mr. T Jul 17 '16 at 21:32
  • 1
    You should put the part about removing no longer used packages in a new question, it's always recommended to only ask about one specific issue per post. – Byte Commander Jul 17 '16 at 22:14

1 Answers1

4

You can find out what software packages contain a specific file (or directory) using the command

dpkg -S /PATH/TO/FILE_OR_DIRECTORY

This only works for installed packages and only for files/directories that are contained in the package. It does not recognize files/directories that were created by the installation scripts or later by the running application.


To find out whether a file is currently opened by any applications, you can use the command

lsof /PATH/TO/FILE_OR_DIRECTORY

No output means that the file is currently not opened by anything. Otherwise you get one line per application that is currently using the file.


If both commands have no outputs and therefore suggest that the file is not needed, probably you can safely delete it. I can't guarantee that it is not needed for anything you might want any more, of course, but I think your chances are pretty good.

It can't really be a system-relevant file anyway as it is in your home directory, but no idea how it got there.

The safest thing is to move it anywhere as backup for another few months or so until you're really 100% sure you don't need it.

Byte Commander
  • 105,631
  • 46
  • 284
  • 425
  • So can I delete the kernel file I found since the commands returned nothing? – Mr. T Jul 17 '16 at 21:40
  • *Probably* you can safely delete it. I can't guarantee that it is not needed for anything you might want any more, of course, but I think your chances are pretty good. It can't really be a system-relevant file anyway as it is in your home directory, but no idea how it got there. The safest thing is to move it anywhere as backup for another few months or so until you're really 100% sure you don't need it. I can't give you more advice than that. – Byte Commander Jul 17 '16 at 22:12