Bash Clear DNS Cache

w‮‬ww.lautturi.com
Bash Clear DNS Cache

In Bash, you can clear the DNS (Domain Name System) cache using the systemd-resolve command. The systemd-resolve command is a command-line utility that is used to manage DNS names and addresses on Linux systems.

To clear the DNS cache, you can use the systemd-resolve command with the --flush-caches option. For example, to clear the DNS cache, you can use the following command:

sudo systemd-resolve --flush-caches

This will clear the DNS cache on your system. Keep in mind that you will need to have root privileges (using the sudo command) to clear the DNS cache.

Additionally, some Linux systems may not have the systemd-resolve command installed by default. If you get an error saying that the systemd-resolve command is not found, you can try installing the systemd-resolved package, which provides the systemd-resolve command. To do this, you can use the following command:

sudo apt-get install systemd-resolved

This will install the systemd-resolved package and all of its dependencies. Once the installation is complete, you should be able to use the systemd-resolve command to clear the DNS cache on your system.

Remember that the systemd-resolve command is specific to Linux systems that use the systemd init system. If you are using a different Linux distribution or a different operating system, you may need to use a different command to clear the DNS cache. Refer to the documentation for your specific operating system for more information.

Created Time:2017-10-16 14:38:38  Author:lautturi