How to Disconnect from Wi-Fi in Ubuntu: A Complete Guide

operating system Ubuntu, based on the kernel Linux, provides users with extensive network interface management capabilities, but the standard graphical interfaces aren't always intuitive for beginners. Situations often arise where you need to instantly disconnect from a wireless network to save your laptop's battery or switch to a wired connection for greater stability. Unlike Windows, where the switch is often visible, in Linux distributions, the approach to network management can vary depending on the desktop shell used, whether it's GNOME, KDE Plasma or XFCE.

Understanding how to effectively manage network connections is a basic skill for any administrator or advanced user. Disabling Wi-Fi may be necessary not only to save power but also for security reasons, such as when you're in a restricted area and don't want the system to automatically connect to open access points. In this article, we'll cover various connection termination methods in detail, from simple mouse clicks to powerful command-line utilities that give you complete control over your network adapter.

Some methods require superuser privileges, as they affect system services that manage the network. We'll look at using the utility. NetworkManager, which is the de facto standard for most modern distributions, and we will also touch on lower-level tools like ip And ifconfigIt's important to choose the method that best suits your current task and your comfort level with the command line.

Using the GNOME graphical interface

The most obvious and easiest way to disable a wireless network is Ubuntu with shell GNOME — this is using the system menu. In the upper right corner of the screen, where the sound and battery indicators are usually located, is a network icon. Clicking it opens a drop-down menu showing a list of available networks and the current connection status.

To disable Wi-Fi, simply toggle the slider to the "Off" position. This immediately disconnects the active connection and disables the wireless module, putting it into power-saving mode. The graphical interface is convenient because it visually displays the status, and you immediately see that the network is disconnected, as the Wi-Fi icon disappears or changes its appearance.

However, the graphical interface may become unresponsive if the system freezes or there are driver issues. In such situations, visual switching may fail, and the system will continue to attempt reconnection in the background. Therefore, knowing alternative methods that don't rely on the graphical interface is critical for effective system management.

⚠️ Attention: If the switch in the GUI doesn't respond, this may indicate a NetworkManager service failure. In this case, try restarting the service via the terminal before trying again.

In some versions of Ubuntu, settings may be buried deeper in the "Options" menu. More detailed settings can be found there, including managing individual connection profiles. This is useful if you want to not only disable Wi-Fi, but also prevent the system from automatically connecting to certain networks in the future.

Disabling via terminal using nmcli

Utility nmcli (Network Manager Command Line Interface) is a powerful tool for managing networks from the command line. It allows you to perform virtually all the same actions as the graphical interface, but with greater flexibility and speed. Disabling Wi-Fi is as simple as executing a single command that sends a signal to the network manager.

To disable the wireless interface, open a terminal and enter a command that puts the device into the "down" state. This action is equivalent to turning off the slider in the GUI, but it's instantaneous. The command looks like this:

nmcli radio wifi off

This command disables the Wi-Fi radio module completely. If you simply need to disconnect from a specific access point but leave the module enabled for scanning, you can use the command to disable a specific device. First, find out the device name by running the command nmcli device status, and then apply the disable action to the desired interface.

  • 📡 Team nmcli radio wifi off Turns off the wireless adapter completely.
  • 🔌 Team nmcli device disconnect wlan0 breaks the connection but leaves the adapter active.
  • 🔍 Use nmcli device status to check the current status of all network interfaces.
  • ⚡ Changes take effect immediately and do not require a system restart.

Usage nmcli This is especially convenient when writing automation scripts or remotely managing a server via SSH. You can be sure that the command will be executed correctly even if the graphical shell isn't running or is unstable. This makes the terminal method preferable for system administrators.

📊 How do you prefer to manage your network in Linux?
Graphical user interface (GUI) only
Terminal only (CLI)
I combine both methods
I use third-party utilities

Managing network interfaces via ip and ifconfig

For deeper network management, bypassing high-level managers like NetworkManager, you can use system utilities ip And ifconfigThese tools work directly with the operating system kernel and network drivers. They are part of the packages iproute2 And net-tools respectively.

Team ip link set allows you to change the state of the network interface. To disable Wi-Fi, you need to know the exact name of your wireless interface, which usually begins with "w" (e.g. wlp2s0 or wlan0). Executing the command requires superuser rights, so add sudo.

sudo ip link set wlp2s0 down

A similar result can be obtained using the utility ifconfig, although it is considered obsolete and is replaced by in many modern distributions ipThe syntax here is even simpler: you specify the interface name and the down parameter. However, if NetworkManager is active on the system, it may attempt to automatically restore the connection if it detects that the interface has gone down.

Team Plastic bag Status Description of action
nmcli radio wifi off network-manager Recommended Disable Wi-Fi radio via the network manager
ip link set dev down iproute2 Relevant Administratively lowers the interface (low-level)
ifconfig wlan0 down net-tools Outdated The classic way to disable the interface
rfkill block wifi rfkill Specific Blocks the device at the kernel level (soft block)

Using low-level commands is useful for diagnosing driver issues. If the interface doesn't come up after the command up or does not go down after down, this may indicate problems with the kernel module or the physical state of the hardware. In such cases, the system log (dmesg) will help to identify the cause of the failure.

Why does the interface immediately turn back on?

If you've disabled Wi-Fi via ip or ifconfig, but NetworkManager is active, it may detect this as an error and attempt to automatically reconnect. For a permanent disconnect, it's best to use nmcli or temporarily stop the NetworkManager service.

Blocking wireless devices using rfkill

Utility rfkill is designed to manage the state of wireless devices in Linux. It provides an interface for setting the lock state of wireless transmitters. This is especially useful when you need to programmatically "turn off" a device, as if you were flipping a physical switch on your laptop.

Team rfkill list Displays a list of all wireless devices and their current status. You'll see whether a device is blocked by software (soft block) or hardware (hard block). To disable Wi-Fi, use the block command, which applies to all Wi-Fi devices.

sudo rfkill block wifi

After executing this command, the wireless module enters the lock state. Unlike simply lowering the interface, rfkill Prevents any attempts by the driver to use the device. This is a reliable way to ensure that Wi-Fi won't work even if other services try to activate it.

⚠️ Attention: Don't confuse a soft lock with a hard lock. A hard lock is set by a physical switch on the laptop or a keyboard button (e.g., Fn+F2) and cannot be removed programmatically without interacting with that switch.

To turn Wi-Fi back on, you need to use the command sudo rfkill unblock wifiIf the device remains locked after this command, check the physical switches on the computer case. Sometimes the locked state can become stuck, requiring a full system reboot to reset the controller.

Automation and scripting

For users who frequently switch between network modes, creating a custom script is a convenient solution. This allows you to perform a complex sequence of actions with a single click or keyboard shortcut. The script can be placed on the desktop or added to the taskbar.

Create a file with the extension .sh, For example toggle_wifi.sh, and place the logic for checking the current state and performing the opposite action in it. You can use the output of the command for this. nmcli radio wifi to determine the status. Below is an example of a simple switch script.

#!/bin/bash

if nmcli radio wifi | grep -q"enabled"; then

nmcli radio wifi off

echo "Wi-Fi is off"

else

nmcli radio wifi on

echo "Wi-Fi is on"

fi

After creating the file, don't forget to make it executable using the command chmod +x toggle_wifi.shYou can now run this script in the terminal or integrate it into a graphical menu. This is especially useful for developers testing application behavior during network interruptions or for those monitoring power consumption.

  • 📝 Scripts allow you to automate routine network management tasks.
  • ⚙️ You can bind the script launch to a hotkey through the keyboard settings.
  • 🛡️ Use sudo inside the script carefully, requesting permissions only when necessary.
  • 🔄 Logging script actions will help debug potential errors in the future.

☑️ Create a Wi-Fi control script

Completed: 0 / 5

Solution and diagnostics

Sometimes the Wi-Fi disconnection process can encounter difficulties. For example, the interface may become unresponsive, or the system may endlessly attempt to reconnect. This is often due to conflicts between various network managers, such as NetworkManager And wicd, which can be installed simultaneously.

If standard methods don't work, try restarting the network management service. This often resolves issues with interfaces stuck in "stuck" states. The command to restart the service on systems running systemd is: sudo systemctl restart NetworkManagerAfter this, try turning off Wi-Fi again.

It's also worth checking whether your firewall or antivirus software is blocking changes to network settings. While this is less common in Linux than in Windows, the configuration iptables or ufw may affect the behavior of network interfaces. Ensure that your user has the necessary permissions to manage the network.

⚠️ Attention: Interfaces and command names may vary slightly depending on the Ubuntu version and desktop environment installed. Always check the latest documentation for your specific distribution if the standard commands don't work.

In case of complete inoperability of the wireless module, when it disappears from the list of devices even after the command ip link, a kernel module loading check may be required. The command lsmod | grep wifi will show whether the driver is loaded. If the module is not loaded, you can try loading it manually with the command modprobe, specifying the driver name.

Frequently Asked Questions (FAQ)

How to permanently disable Wi-Fi so it doesn't turn on during boot?

To disable it permanently, you can create a configuration file for NetworkManager that disables Wi-Fi management, or use the command nmcli radio wifi off in startup scripts. You can also block the kernel module via blacklist in the modprobe config, but this will disable the driver completely.

Why doesn't the sudo nmcli radio wifi off command work?

This may occur if the NetworkManager service is not running, or if you do not have superuser rights. Also, check if the device is hard blocked. rfkill listIf there is a hard lock, it will not be possible to remove it programmatically.

Is it possible to disable only network scanning while keeping the connection active?

There's no direct way to completely disable background scanning while maintaining the connection in the standard NetworkManager, as scanning is necessary for signal quality assessment and roaming. However, you can reduce the scanning frequency in the configuration files, but this may lead to connection instability.

How do I find out the name of my wireless interface?

Use the command ip link or iwconfigWireless interfaces typically have names that begin with "w" (e.g. wlan0, wlp3s0). In the command output ip link they are often labeled as a condition NO-CARRIER or UP indicating the link/ether type.