{"id":379,"date":"2022-11-26T18:02:51","date_gmt":"2022-11-26T18:02:51","guid":{"rendered":"https:\/\/blog.inplico.uk\/?p=379"},"modified":"2025-08-17T21:10:03","modified_gmt":"2025-08-17T20:10:03","slug":"command-line-wifi-debian","status":"publish","type":"post","link":"https:\/\/blog.inplico.uk\/?p=379","title":{"rendered":"Command line wifi &#8211; Debian"},"content":{"rendered":"<p>If you want Debian working with wifi on every reboot then you need to configure it. First thing to do is make sure the interface is up using<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ip link show<\/pre>\n<p>If not then bring it up:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ip link set up wlp2so<\/pre>\n<p>NOTE: your network interface name might be different.<\/p>\n<p>One is assuming that you know the SSID of your wifi network but this may be a helpful tool to check that the hardware is working.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">iwlist scan | grep ESSID<\/pre>\n<p>This should return a list of available networks.<\/p>\n<p>&nbsp;<\/p>\n<p>For WPA2-PSK networks (which is all I really care about ATM) you need to issue the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$ su -l -c \"wpa_passphrase myssid my_very_secret_passphrase &gt; \/etc\/wpa_supplicant\/wpa_supplicant-wlp2s0.conf\"<\/pre>\n<p>NOTE: the text &#8220;wpa_passphrase&#8221; is literal\u00a0 &#8220;myssid&#8221; need changing to the SSID that you wish to connect to and you also need to change &#8220;my_very_secret_passphrase&#8221; to your wifi password.<\/p>\n<p>WARNING: The naming of the file is important as if you do not name it correctly then the service will not start.\u00a0 You must append &#8220;wpa_supplicant&#8221; with a hyphen &#8216;-&#8216; followed by the interface name.<\/p>\n<p>Now if you review the file that the previous command has created then it should look something like:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">network={\r\n        ssid=\"myssid\"\r\n        #psk=\"my_very_secret_passphrase\"\r\n        psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b\r\n}<\/pre>\n<p>Now you can enable wpa_supplicant by issuing<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">systemctl enable wpa_supplicant@wlp2S0<\/pre>\n<p>and now you should be able to start the service.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Legacy method:<\/strong><\/p>\n<p>You have a couple of options as to what to do next.\u00a0 For Debian based systems the traditional way is as follows:<\/p>\n<p>Next configure \/etc\/network\/interfaces by adding the following 2 lines<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">allow-hotplug wlp2s0\r\niface wlp2s0 inet dhcp\r\n<\/pre>\n<p>Obviously you can set a static ip here in the usual way if you wish.<\/p>\n<p>Finally<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ifup wlp2s0<\/pre>\n<p>should start then network.<\/p>\n<p>&nbsp;<\/p>\n<p>ADDITIONAL:<\/p>\n<p>if you want to enable wpa_cli then according to the debian wiki you need to append the following to the wpa_supplicant.conf file<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">ctrl_interface=\/run\/wpa_supplicant \r\nupdate_config=1<\/pre>\n<p>&nbsp;<\/p>\n<p>https:\/\/support.speedify.com\/article\/826-connect-different-wi-fi-interfaces-to-different-networks-linux<\/p>\n<p>demonstrates how to use wpa_cli to add more networks:<\/p>\n<p>&nbsp;<\/p>\n<p>This is taken from the speedify website (Currently untested).<\/p>\n<p>&#8220;When starting the wpa_cli, you can select the interface you want to configure using the -i argument.<\/p>\n<p>For example:<\/p>\n<p>wpa_cli -i wlan0<\/p>\n<p>It will launch into an interactive mode where you can set options. From here you can confirm that the adapter is scanning and seeing networks by running:<\/p>\n<p>scan<\/p>\n<p>scan_results<\/p>\n<p>That should show a list of the available wireless networks. Then you can add and configure a network, analogous to what you would put in the wpa_supplicant.conf file.<\/p>\n<p>If you\u2019ve already been playing with adding networks in the wpa_supplicant.conf file, you might want to remove them, or you can directly modify them with the wpa_cli tool.<\/p>\n<p>Run<\/p>\n<p>list_networks<\/p>\n<p>to see any existing network configurations. If you already have one in the list, you can modify by using its ID in the command below. Otherwise, add a new network and take notes of its ID.<\/p>\n<p>add_network<\/p>\n<p>set_network &lt;ID&gt; ssid &#8220;The WiFi SSID&#8221;<\/p>\n<p>set_network &lt;ID&gt; psk &#8220;password&#8221;<\/p>\n<p>enable_network &lt;ID&gt;<\/p>\n<p>If you have multiple network configurations, you might need to do:<\/p>\n<p>select_network &lt;ID&gt;<\/p>\n<p>If it is a simple network, that should be enough to get it to start connecting to the Wi-Fi network. You can save the configuration by running:<\/p>\n<p>save_config<\/p>\n<p>You can then quit out of the wpa_cli session and start it with the next interface and repeat the above steps.&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Systemd built in network manager<\/strong><\/p>\n<p>Instead of using a separate network manager it is now possible to use the built in systemd-networkd<\/p>\n<p>You create a file for each interface and.\u00a0 The files are prefixed with a number (a priority) and have the &#8220;<strong>.network<\/strong>&#8221; suffix. and should be placed in <strong>\/etc\/systemd\/network.<\/strong><\/p>\n<p>To configure the wifi interface set up wpa_supplicant as directed and then create a configuration file<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">touch \/etc\/systemd\/network\/20-somename.network<\/pre>\n<p>For a simple dhcp example you just put<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">[Match]\r\nName=wlp2s0\r\n[Network]\r\nDHCP=yes\r\n<\/pre>\n<p>in the file and and save it.\u00a0 Make sure to enable and start systemd-networkd.\u00a0 You can check if the interface is up with either &#8220;ip a&#8221; or &#8220;networkctl&#8221;<\/p>\n<p>NOTE:\u00a0 make sure you don&#8217;t have any other network manager services running if you are going to use this method.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want Debian working with wifi on every reboot then you need to configure it. First thing to do is make sure the interface is up using ip link show If not then bring it up: ip link set up wlp2so NOTE: your network interface name might be different. One is assuming that you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-379","post","type-post","status-publish","format-standard","hentry","category-debian-server"],"_links":{"self":[{"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=\/wp\/v2\/posts\/379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=379"}],"version-history":[{"count":3,"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=\/wp\/v2\/posts\/379\/revisions"}],"predecessor-version":[{"id":537,"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=\/wp\/v2\/posts\/379\/revisions\/537"}],"wp:attachment":[{"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.inplico.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}