{"id":12214,"date":"2019-03-23T15:02:29","date_gmt":"2019-03-23T15:02:29","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12214"},"modified":"2019-03-23T15:02:29","modified_gmt":"2019-03-23T15:02:29","slug":"how-to-connect-wi-fi-from-linux-terminal-using-nmcli-command","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/23\/how-to-connect-wi-fi-from-linux-terminal-using-nmcli-command\/","title":{"rendered":"How to Connect Wi-Fi from Linux Terminal Using Nmcli Command"},"content":{"rendered":"<p>There are several command-line tools for managing a wireless network interface in Linux systems. A number of these can be used to simply view the wireless network interface status (whether it is\u00a0<strong>up<\/strong>\u00a0or\u00a0<strong>down<\/strong>, or if it is connected to any network), such as\u00a0<strong>iw<\/strong>,\u00a0<strong>iwlist<\/strong>,\u00a0<a href=\"https:\/\/www.tecmint.com\/ip-command-examples\/\" target=\"_blank\" rel=\"noopener\">ip<\/a>,\u00a0<a href=\"https:\/\/www.tecmint.com\/ifconfig-command-examples\/\" target=\"_blank\" rel=\"noopener\">ifconfig<\/a>\u00a0and others.<\/p>\n<p>And some are used to connect to a wireless network, and these include:\u00a0<a href=\"https:\/\/www.tecmint.com\/configure-network-connections-using-nmcli-tool-in-linux\/\" target=\"_blank\" rel=\"noopener\">nmcli<\/a>, is a command-line tool used to create, show, edit, delete, enable, and disable network connections, as well as control and display network device status.<\/p>\n<p>First start by checking the name of your network device using the following command. From the output of this command, the device name\/interface is\u00a0<strong>wlp1s0<\/strong>\u00a0as shown.<\/p>\n<pre><strong>$ iw dev<\/strong>\r\n\r\nphy#0\r\n\tInterface <strong>wlp1s0<\/strong>\r\n\t\tifindex 3\r\n\t\twdev 0x1\r\n\t\taddr 38:b1:db:7c:78:c7\r\n\t\ttype managed\r\n<\/pre>\n<p>Next, check the Wi-Fi device connection status using the following command.<\/p>\n<pre><strong>iw wlp2s0 link<\/strong>\r\n\r\n<strong>Not connected.<\/strong>\r\n<\/pre>\n<p><center>From the output above the device is not connected to any network, run the following command to scan available Wi-Fi networks.<\/center><\/p>\n<pre><strong>sudo iw wlp2s0 scan<\/strong>\r\n       \r\n<strong>command failed: Network is down (-100)<\/strong>\r\n<\/pre>\n<p>Considering the output of the above command, the network device\/interface is\u00a0<strong>DOWN<\/strong>, you can turn it\u00a0<strong>On<\/strong>\u00a0<strong>(UP<\/strong>) with the\u00a0<a href=\"https:\/\/www.tecmint.com\/ip-command-examples\/\" target=\"_blank\" rel=\"noopener\">ip command<\/a>\u00a0as shown.<\/p>\n<pre>$ sudo ip link set wlp1s0 up\r\n<\/pre>\n<p>If you get the following error, that means your Wifi is hard blocked on Laptop or Computer.<\/p>\n<pre>RTNETLINK answers: Operation not possible due to RF-kill\r\n<\/pre>\n<p>To remove or unblock you need to run the following command to solve the error.<\/p>\n<pre>$ echo \"blacklist hp_wmi\" | sudo tee \/etc\/modprobe.d\/hp.conf\r\n$ sudo rfkill unblock all\r\n<\/pre>\n<p>Then try to turn\u00a0<strong>ON<\/strong>\u00a0the network device once more, and it should work this time around.<\/p>\n<pre>$ sudo ip link set wlp1s0 up\r\n<\/pre>\n<p>If you know the\u00a0<strong>ESSID<\/strong>\u00a0of the Wi-Fi network you wish to connect to, move to the next step, otherwise issue the command below to scan available Wi-Fi networks again.<\/p>\n<pre>$ sudo iw wlp1s0 scan\r\n<\/pre>\n<p>And lastly, connect to the wi-fi network using following command, where\u00a0<strong>Hackernet<\/strong>\u00a0(Wi-Fi network SSID) and\u00a0<strong>localhost22<\/strong>\u00a0(password\/pre-shared key).<\/p>\n<pre>$ nmcli dev wifi connect Hackernet password localhost22<\/pre>\n<p>Once connected, verify your connectivity by doing a ping to an external machine and analyze the output of the ping as shown.<\/p>\n<pre><strong>$ ping 8.8.8.8<\/strong>\r\n\r\nPING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\r\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=48 time=61.7 ms\r\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=48 time=61.5 ms\r\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=48 time=61.6 ms\r\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=48 time=61.3 ms\r\n64 bytes from 8.8.8.8: icmp_seq=5 ttl=48 time=63.9 ms\r\n^C\r\n--- 8.8.8.8 ping statistics ---\r\n5 packets transmitted, 5 received, 0% packet loss, time 4006ms\r\nrtt min\/avg\/max\/mdev = 61.338\/62.047\/63.928\/0.950 ms\r\n<\/pre>\n<p>That\u2019s It! I hope this article helped you to setup your\u00a0<strong>Wi-Fi<\/strong>\u00a0network from the Linux command line.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/nmcli-connect-wi-fi-from-linux-terminal\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are several command-line tools for managing a wireless network interface in Linux systems. A number of these can be used to simply view the wireless network interface status (whether it is\u00a0up\u00a0or\u00a0down, or if it is connected to any network), such as\u00a0iw,\u00a0iwlist,\u00a0ip,\u00a0ifconfig\u00a0and others. And some are used to connect to a wireless network, and these &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/23\/how-to-connect-wi-fi-from-linux-terminal-using-nmcli-command\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Connect Wi-Fi from Linux Terminal Using Nmcli Command&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12214","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12214"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12214\/revisions"}],"predecessor-version":[{"id":12215,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12214\/revisions\/12215"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}