0

After a CentOS 7 Minimal install, and a yum update, I analyzed the folders. The following folders either have nothing inside them, or they only have inside them folders which have nothing inside them (this isn't an exhaustive or complete list):

  • /home/
  • /media/
  • /opt/
  • /lost+found/
  • /mnt/
  • /usr/etc/
  • /usr/games/
  • /usr/local/

Can these folders be safely deleted, or could there be bad repercussions for doing so?

migrated from webmasters.stackexchange.com Oct 28 '18 at 23:21

This question came from our site for pro webmasters.

  • The issue is that, in the future, a program you install may look for these to exist and if they are not present not work. These are present because they will be needed. /mnt is where things are mounted such as your hard drive, /home is for you users (do not run a server with root as your only user!), /usr/* is used for read-only user data, most of your utilities and third-party software will be kept in various places in /usr or /opt. It is better to practice good control over the access rights of these instead of deleting them. – kemotep Oct 28 '18 at 23:56
  • @kemotep Good to know, and good advice! Thanks! – abcjme Oct 29 '18 at 0:12
2

The only directory that I would be confident saying could be deleted is the empty lost+found directory. It would be recreated by fsck if that tool repairs the filesystem and finds dangling inodes (see "What is the purpose of the lost+found folder in Linux and Unix?").

The other directories may be used or may be assumed exist by various system tools, applications and/or package managers on your system. In particular, deleting /home, /mnt, and /usr/local (and possibly /media) may well upset some software that relies on these directories being present. Both /mnt and /media (on Linux) are often used for mounting external drives, and /home will contain your users' home directories (including your own).

A most general advice is to not blindly change things installed by default by your Linux distribution. The defaults (be it permissions on files or directories or various other configurations) have been tested by the distribution maintainers, and are supposed to work. Obviously, you may need to tweak things so that they suit your needs, but, you know, not blindly.

0

Clearly: yes they can be safely deleted, and have no need to be on the filesystem. Linux will continue to run, and most installed software will work properly.

But as already mentioned, when installing new packages they might ecpect that the folders are existing. So it might happen, that installing packages wanting to write/install files in these locations might fail. Or another pitfall can be useradd expecting /home to be existing.

Typically there is also no need to remove these directories, it will not free up much disk space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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