LinuxCommandLibrary

rfkill

Enable or disable wireless devices

TLDR

List devices

$ rfkill
copy

Filter by columns
$ rfkill [[-o|--output]] [ID,TYPE,DEVICE]
copy

Block devices by type (e.g. bluetooth, wlan)
$ rfkill block [bluetooth]
copy

Unblock devices by type (e.g. bluetooth, wlan)
$ rfkill unblock [wlan]
copy

Output in JSON format
$ rfkill [[-J|--json]]
copy

SYNOPSIS

rfkill [options] command
rfkill list [ID]
rfkill block ID|TYPE
rfkill unblock ID|TYPE
rfkill event
rfkill help

PARAMETERS

list [ID]
    Lists the state of rfkill switches. If ID is provided, it lists only that specific device. It shows the device ID, type, and whether it's software or hardware blocked.

block ID|TYPE
    Blocks the radio for a specific device identified by ID or for all devices of a certain TYPE. This sets the software kill switch.

unblock ID|TYPE
    Unblocks the radio for a specific device identified by ID or for all devices of a certain TYPE. This removes the software kill switch.

event
    Monitors and prints rfkill events. Useful for seeing when a hardware kill switch is toggled or when software blocks are applied by other processes.

help
    Displays a concise help message for the rfkill command.

-o format, --output format
    Defines the output columns for the list command. Common columns include ID, TYPE, DEVICE, SOFT, HARD.

-n, --noheadings
    Suppresses the header row when using the list command, useful for scripting.

-J, --json
    Outputs the list command results in JSON format, facilitating programmatic parsing.

DESCRIPTION

The rfkill command manages the radio kill switch for wireless devices on Linux systems. It interacts with the kernel's rfkill subsystem, which provides a unified interface for enabling or disabling wireless communication. This includes technologies like Wi-Fi, Bluetooth, 3G/4G/5G (WWAN), UWB, WiMAX, and NFC. rfkill can block or unblock devices based on their unique ID or by technology type. It distinguishes between a software block (controlled by the OS) and a hardware block (a physical switch on the device, often on laptops). A hardware block always overrides a software block. This utility is crucial for quickly disabling all wireless transmitters, for example, when entering an airplane mode or for security reasons.

CAVEATS

`rfkill` primarily controls the software kill switch. If a device has a physical hardware kill switch (e.g., a button or lever on a laptop), that hardware switch will always override the software setting. If the hardware switch is engaged, `rfkill unblock` will not enable the device until the hardware switch is disengaged.
For `rfkill` to list or control a device, the kernel must have appropriate support for that device's radio via its driver and the `rfkill` subsystem.
Executing `rfkill block` or `unblock` typically requires root privileges (or CAP_NET_ADMIN capability) as it modifies system-wide network settings.

BLOCK TYPES

When using block or unblock, TYPE can be one of the following to target specific wireless technologies:
all: Affects all listed rfkill devices.
wifi: Affects Wi-Fi devices.
bluetooth: Affects Bluetooth devices.
uwb: Affects Ultra-Wideband devices.
wimax: Affects WiMAX devices.
wwan: Affects Wireless WAN (3G/4G/5G modems) devices.
nfc: Affects Near Field Communication devices.

IDS

Each wireless device detected by the rfkill subsystem is assigned a unique numerical ID. You can find these IDs by running rfkill list. This ID is used to target a specific device when blocking or unblocking, ensuring precise control over individual radios.

SOFTWARE VS. HARDWARE BLOCKS

Understanding the distinction is crucial:
Software Block: This is controlled by the operating system, often via rfkill or other network management tools. It can be toggled by the user or system processes.
Hardware Block: This is a physical switch or mechanism on the device itself (e.g., a laptop's Wi-Fi button). When engaged, it directly cuts power or signal to the radio, bypassing software controls. A hardware block takes precedence over any software unblock. If rfkill list shows a device as Hard blocked: yes, you must physically toggle the switch to enable it.

HISTORY

The rfkill subsystem and utility were introduced to the Linux kernel and userspace to provide a standardized way of controlling wireless devices across different hardware vendors and wireless technologies. Prior to its existence, device-specific methods were often required to disable radios. `rfkill` simplifies this by offering a unified interface. It is part of the widely used util-linux package, which provides a variety of essential system utilities. Its development reflects the increasing prevalence of wireless communication and the need for robust control mechanisms, especially concerning power management and regulatory compliance.

SEE ALSO

ip(8), iw(8), nmcli(1), systemctl(1)

Copied to clipboard