Uninstallation
The wireguard-install
script provides a straightforward way to completely remove the WireGuard installation and all associated configuration files.
How to Uninstall
-
Run the installation script from the directory where you downloaded it:
./wireguard-install.sh
-
When the management menu appears, select option
4
:What do you want to do? 1) Add a new user 2) List all users 3) Revoke existing user 4) Uninstall WireGuard 5) Exit Select an option [1-5]: 4
-
The script will display a critical warning. You must confirm that you want to proceed with the removal.
WARNING: This will uninstall WireGuard and remove all the configuration files! Please backup the /etc/wireguard directory if you want to keep your configuration files. Do you really want to remove WireGuard? [y/n]: y
What the Uninstaller Does
Upon confirmation, the script performs the following actions to clean the system:
-
Stops and Disables the Service: It stops the active
wg-quick@wg0
service and disables it to prevent it from starting on the next boot. -
Removes Packages: It uses the system's native package manager (
apt
,yum
,dnf
,pacman
,apk
) to remove thewireguard-tools
andqrencode
packages. -
Deletes Configuration Directory: It completely removes the
/etc/wireguard
directory, which contains the server configuration, keys, and theparams
file. This action is irreversible. -
Removes Sysctl Configuration: It deletes the
/etc/sysctl.d/wg.conf
file to disable IP forwarding on the next reboot. -
Reloads System Configuration: It runs
sysctl --system
to apply the removal of the IP forwarding rule immediately.
After these steps are completed, WireGuard will be fully removed from your system.