Is it ok to delete the /srv directory?

Is it okay to remove the srv$ directory in Kubuntu 20.04

There seems to be no files contained inside and it will clear up the structure.

after research I found that it was very much up to what I want with the system.

Asked By: mortenlund


Kubuntu uses dpkg to manage packages. dpkg -S <path> will tell you why that path exists as long as it was created by a package installation.

Here are some examples:

$ dpkg -S /srv
dpkg-query: no path found matching pattern /srv

$ dpkg -S /var/www
apache2: /var/www

On my system, no package ‘owns’ /srv. That means no software installed with apt should break if I delete /srv. By contrast, /var/www is owned by apache2. If I delete /var/www, then apache2 may encounter problems.

However, this only applies to software installed with the system’s package manager. If you rely on something installed with sudo make install, then dpkg may give you a false negative. This is one of the many reasons I avoid installing unpackaged applications.

Another place to check for the usage of /srv is in your local configuration.

$ cd /etc
$ grep -r /srv
passwd:ftp:x:130:139:ftp daemon,,,:/srv/ftp:/usr/sbin/nologin

Here, I can see in passwd, I have a system user called ftp which uses /srv/ftp as a home directory. If I delete /srv/ftp, then I may not be able to use my home FTP server. However that directory is empty, and my vsftp settings don’t use that directory, so in my case, this would be fine to delete.

I can also see /etc/schroot/schroot.conf refers to /srv. Reading the file, I can see it’s only in the context of an example configuration. Therefore I know it’s also safe to delete here.

Answered By: Stewart