The following text elaborates on Linux
- Linux system (this tutorial uses Ubuntu 22.04).
- Access to the terminal.
- sudo permissions.
Note: For the proper
ifdown functioning, the file /run/network/ifstate must be writable. If it's not, the solution is using sudo or root privileges or
Another option is to make /run/network/ifstate a symbolic link to a writable location.
ifdown Command Syntax
ifdown command syntax is:
ifdown [options] [interface]
ifdown without any options or interface doesn't produce output. The
[interface] components are mandatory. However, options serve to customize the command but are not necessary.
Note: If the
ifdown command is not available on the system, run
sudo apt install ifupdown.
ifdown Command Options
ifdown command has several arguments which change its output. The following table lists
|Deactivates all interfaces.|
|Ignores non-"allow-CLASS" interfaces in /etc/network/interfaces.|
|Uses FILE for interface definitions instead of /etc/network/interfaces.|
|Excludes interfaces from the list of interfaces to operate on by the |
|Simulates the command without actually executing it.|
|Shows what would happen before executing.|
|Doesn't run any mappings.|
|Doesn't run hook scripts.|
|Prints non-verbose output.|
|Prompts the command not to perform any deactivation on the loopback device.|
|Forces the command to run even if the interface is not configured.|
|Signals the command to ignore errors.|
|Prints the help message.|
|Prints copyright and version information.|
--force option addresses a common issue with
ifdown. Network interface records sometimes become inconsistent with the actual states of the interfaces. In such cases,
ifdown to execute deconfiguration commands, irrespective of its perception of the interface's current state.
ifdown Command Examples
Due to the variety of arguments,
ifdown has multiple practical examples. However, before running
ifdown, a user must know the interface names. Use the ip or deprecated ifconfig command to check interface names.
For instance, to verify the interface names with
ip link show
On the other hand, use the following command to accomplish the same:
Both commands show currently active network interfaces.
ifconfig command is deprecated and not always installed in modern Linux systems. To install it, run
sudo apt install net-tools.
The following sections present some
ifdown use cases.
Bring Down Active Interfaces
Do deactivate all interfaces, run:
sudo ifdown -a
The command has no output.
Print Verbose Output
To display additional info in the command output, run the command with
sudo ifdown -av
To verify all interfaces are down, use the ping command. For instance, ping Google with:
The command prints no output.
Disable a Specific Interface
To bring down a specific interface, use the syntax:
sudo ifdown -v [interface][configuration]
This command provides a verbose output. For instance, turn off the specific configuration of the interface lo with:
sudo ifdown -v lo=lo
ip link show to confirm the interface is not listed.
Note: In some cases, bringing up the interface without the configuration is enough. For instance,
sudo ifdown -v lo executes without errors. However, this is not always sufficient.
Simulate Interface Deactivation
Simulating network interface deactivation without altering system configurations is beneficial for testing and development. The procedure allows users to test the deactivation impact before implementing changes to the network, ensuring a controlled and predictable environment. This is especially useful when scripting or automating network interface management processes.
To simulate the command without executing it, run:
ifdown --no-act [configuration][interface]
For instance, to simulate
ifdown on the lo interface without executing the command, run:
ifdown --no-act lo=lo
Note: Automating network configuration for hardware changes may need extra packages (e.g.,
ifplugd), but many Linux distributions include basic networking by default. Check system documentation or the package manager to see if these extras are installed and necessary for your needs.
After reading this article, you know everything about the Linux
ifdown command. Additionally, the guide provided the most common use cases.
To learn about other Linux commands, refer to our Linux commands cheat sheet.