How to bring up a wi-fi interface from a command line?

sudo ip link set wlan0 up or sudo ifconfig wlan0 up.


Answer from Apr 13'17:

To elaborate on the answer by Martin:

ifup and ifdown commands are part of ifupdown package, which now is considered a legacy frontend for network configuration, compared to newer ones, such as network manager.

Upon ifup ifupdown reads configuration settings from /etc/network/interfaces; it runs pre-up, post-up and post-down scripts from /etc/network, which include starting /etc/wpasupplicant/ifupdown.sh that processes additional wpa-* configuration options for wpa wifi, in /etc/network/interfaces (see zcat /usr/share/doc/wpasupplicant/README.Debian.gz for documentation). For WEP wireless-tools package plays similar role to wpa-supplicant. iwconfig is from wireless-tools, too.

ifconfig at the same time is a lower level tool, which is used by ifupdown and allows for more flexibility. For instance, there are 6 modes of wifi adapter functioning and IIRC ifupdown covers only managed mode (+ roaming mode, which formally isn't mode?). With iwconfig and ifconfig you can enable e.g. monitor mode of your wireless card, while with ifupdown you won't be able to do that directly.

ip command is a newer tool that works on top of netlink sockets, a new way to configure the kernel network stack from userspace (tools like ifconfig are built on top of ioctl system calls).


Try ifconfig wlan0 up instead of ifup.


As of Ubuntu 18.04 (and corresponding Debian versions) ifconfig and ifup/ifdown are deprecated, and the recommended way to bring up the interface is with the ip command:

ip link set dev <interface> up
ip link set dev <interface> down

And you can check your available interfaces with:

ip link

And you can show your interfaces' assigned ip addresses with:

ip addr show

Or more specifically:

ip addr show scope global | grep inet