Linux: Configure Wifi over a shell (Wlan)

/etc/network/interfaces

wpa_passphrase myWifi myPassword
network={
  ssid="myWifi"
  #psk="myPassword"
  psk=3a068aa2c481de5089c2345704c40095c5c6d75049809e4ca9b808efba893c5d
}
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid myWifi
wpa-psk 3a068aa2c481de5089c2345704c40095c5c6d75049809e4ca9b808efba893c5d

Stop Network-Manager on Ubuntu:

systemctl stop network-manager
sudo ifup wlan0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/5c:51:4f:cf:0a:5d
Sending on LPF/wlan0/5c:51:4f:cf:0a:5d
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3 (xid=0x1666b12c)
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7 (xid=0x1666b12c)
DHCPREQUEST of 192.168.1.175 on wlan0 to 255.255.255.255 port 67
(xid=0x1666b12c)
DHCPOFFER of 192.168.1.175 from 192.168.1.1
DHCPACK of 192.168.1.175 from 192.168.1.1
bound to 192.168.1.175 -- renewal in 17680 seconds.

iwconfig

iwlist scan | grep ESSID
wpa_passphrase myWifi myPassword > wpa.conf