How to flush the DNS cache in Debian GNU/Linux?

If using systemd-resolved as your DNS resolver (i.e. the hosts line of your /etc/nsswitch.conf file includes the word resolve and/or /etc/resolv.conf contains the line nameserver, then this command will flush its cache:

sudo systemd-resolve --flush-caches

A newer version of this command seems to be:

sudo resolvectl flush-caches