ifup command allows you to view network interfaces in the terminal. It is often used with ifdown and
The following text elaborates on the
ifup command in Linux, its options, and use cases.
Note: To ensure correct
ifup functionality, the /run/network/ifstate file must be writable. If this proves challenging, solutions include employing the sudo command, obtaining root privileges, or using the --force option. Alternatively, create a symbolic link for /run/network/ifstate leading to a location with write permissions.
ifup Command Syntax
ifup command follows this syntax:
ifup [options] [interface]
ifup without specifying any options or interface does not generate any output. While the
[interface] components are obligatory, options are not. Options tailor the command to specific requirements.
Note: If your system doesn't have
ifup, run the command below.
sudo apt install ifupdown
ifup Command Options
ifup command produces varied output based on different arguments. The table below lists the available options.
|Displays what happens before executing the command.|
|Sets a specific network configuration option to a specified value, treating it as defined in the /etc/network/interfaces file.|
|Does not run any hook scripts.|
|Does not treat the loopback device differently from other network interfaces.|
|Prints out the actions that would occur without executing the command.|
|Processes all interfaces marked as automatically activated at the startup.|
|Shows the help message.|
|Prints copyright and version information.|
|Allows users to specify a custom file for defining network interface configurations.|
|Instructs the command to use a specific directory to store state information.|
|Excludes interfaces from the operation based on a specified PATTERN.|
|Stops extra network configuration rules or settings specified through mappings. This allows the network interface to be brought up with minimal or default configuration.|
--force argument resolves a common problem with
ifup. Network interface records occasionally don't accurately reflect the actual states, leading to inconsistencies. When this occurs, using
ifup to carry out configuration commands regardless of the interfaces' current state.
ifup Command Examples
Because ifup supports various arguments, it has multiple practical use cases. However, before executing ifup, users must be aware of the specific interface names. To determine these names, execute the ip command or the deprecated ifconfig command.
Confirm the interface's names with:
ip link show
The second option to verify interfaces is by using:
ifconfig command is not available on all Linux systems. To install it, execute the command below.
sudo apt install net-tools
To make sure interfaces are active, use ping. For instance, ping google.com:
For this tutorial, first execute
ifdown to turn off all the interfaces:
sudo ifdown -av
The command produces verbose output. To verify all interfaces are down, use
ping. For instance:
The output shows interfaces are down.
The following text presents practical
ifup usage examples.
Bring up a Specific Interface
To activate a specific network interface, run the following syntax:
sudo ifup [interface]
For instance, turn on the
enp0s3 interface with:
sudo ifup enp0s3
The command produces no output. Verify the interface is working with
Print Verbose Output
To display additional info in the command output, run the command with
-v. For instance, bring up the
lo interface with:
sudo ifup -v lo
Note: In general, the interface name alone should be sufficient when bringing up the interface. Therefore,
sudo ifup -v [interface] is the typical syntax. However, in some configurations, the syntax is
sudo ifup -v [interface] [configuration]. For example,
sudo ifup -v lo=lo.
Activate all Interfaces
To bring up all interfaces and get the verbose mode, run:
sudo ifup -av
The argument --ignore-errors instructs the system to bring up network interfaces and to proceed with the activation even if errors are encountered during the process.
For instance, to bring up all interfaces, print verbose output, and ignore errors, run:
sudo ifup --ignore-errors -av
Exclude an Interface
--exclude option allows users to specify an interface to be excluded from the list. The syntax for this command is:
sudo ifup --exclude [interface]
For instance, exclude the
lo interface with:
sudo ifup --exclude lo
The command has no output.
Simulate Interface Activation
--no-act option is beneficial when users wish to preview the changes that occur while activating a network interface without actually applying those changes. The syntax is:
ifup --no-act [interface]
For example, simulate
ifup on the
lo interface without executing the command with:
sudo ifup --no-act -v lo
Note:While many Linux distributions have basic networking capabilities installed by default, sometimes automatic network adjustments for hardware changes may require additional packages. To determine if these extra packages are installed and necessary for your specific requirements, refer to the system documentation or consult the package manager.
After reading this tutorial, you are now familiar with the Linux ifup command, syntax, options, and common use case examples.
For more essential commands for networking, check out our Linux network commands cheat sheet.