Command To Connect to Default Wifi?

Technical issues/questions of an intermediate or advanced nature.
johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#1 by johnywhy » 31 Aug 2018, 00:59

Hi

How to connect to the default wifi connection using command line without using NetworkManager?

NetworkManager and nm-applet run continually, and consume RAM. I´m trying to reduce Porteus footprint.

THX
Last edited by johnywhy on 01 Sep 2018, 05:35, edited 3 times in total.

User avatar
Ed_P
Contributor
Contributor
Posts: 8359
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Command To Connect to Default Wifi?

Post#2 by Ed_P » 31 Aug 2018, 06:09

Is this what you were looking for?
johnywhy wrote:
31 Aug 2018, 04:18
recovered net by typing nm-applet at command prompt.
it auto-connected, then on reboot connected again.
Ed

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#3 by johnywhy » 31 Aug 2018, 07:03

nope. that's the normal way to do it.
i want to call lower-level functions. Maybe the same functions nm-applet calls.

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#4 by johnywhy » 31 Aug 2018, 16:58

This works for me:

drop to root
# su

it seems NetworkManager locks the device, so i have to kill NetworkManager and nm-applet processes before connecting:
# kill `pgrep NetworkManager`
# kill `pgrep nm-applet`


gentler way is:
# /etc/rc.d/networkmanager stop
(equivalent on non-porteus systemd OS's: # systemctl stop NetworkManager)

Assume wireless device is called wlan0:

To connect:

1. turn on wireless
# ifconfig wlan0 up

2. connect to named no-password connection
# iwconfig wlan0 essid [ConnectionName]

3. flush old ip address
# ip addr flush dev wlan0

4. get dhcp ip-address
# dhclient wlan0

-----
Connect to WPA/WEP with password:
(i have not tried these)

connect to named connection with WEP password
# iwconfig wlan0 essid ConnectionName key s:MyPassword

connect to named connection with WPA/WPA2 password, see post below.
-----
More useful commands:

disable network manager at boot:
# chmod -x /etc/rc.d/rc.networkmanager
(equivalent on non-porteus systemd OS's: # systemctl disable NetworkManager)

show network devices, to get name of your wireless device (eg wlan0):
# iwconfig

show state of wireless (connected, not connected, off):
# iwconfig wlan0

list available wifi hotspots:
# iwlist wlan0 s | grep ESSID

see history of system wireless messages
# dmesg | grep wlan0

These commands could be wrapped up in a very simple gui. No need to run services in the background continually.
-----
awesome resource:
https://askubuntu.com/a/16588
Last edited by johnywhy on 01 Sep 2018, 15:10, edited 19 times in total.

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#5 by johnywhy » 31 Aug 2018, 17:55

there surely exists a simple iwconfig GUI that will run on Porteus.
anybody know of one?

I´ve found these, but no luck running them yet:

apradar-0.52-1.i586.rpm http://apradar.sourceforge.net
gtkwifi-1.10.tar.bz2 https://sourceforge.net/projects/gtkwifi/
gwireless_applet-0.8.tar.gz https://sourceforge.net/projects/gwifiapplet/
netchoose-0.2-1.i386.rpm http://www.plutospin.com/netchoose.html
wicd-1.7.3.tar.gz https://launchpad.net/wicd
wlassistant-0.5.7-i386-1.tgz https://sourceforge.net/projects/wlassistant/
Very Simple Wireless Manager https://github.com/dmelo/vswm

https://www.techrepublic.com/blog/10-th ... -in-linux/
Last edited by johnywhy on 31 Aug 2018, 21:42, edited 1 time in total.

donald
Full of knowledge
Full of knowledge
Posts: 2067
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Command To Connect to Default Wifi?

Post#6 by donald » 31 Aug 2018, 20:54

johnywhy wrote:
31 Aug 2018, 16:58
# wpa-supplicant ???
i don´t see wpa-supplicant on Porteus

Code: Select all

guest@porteus:~$ whereis wpa_supplicant
wpa_supplicant: /usr/sbin/wpa_supplicant /etc/wpa_supplicant.conf

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#7 by johnywhy » 31 Aug 2018, 21:24

thx, @donald!

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#8 by johnywhy » 31 Aug 2018, 21:34

WPA/WPA2 method (not tested on Porteus) with stored connections:

Create file wpa_supplicant.conf, describing all networks that the user wants the computer to connect to. Replace ESSID and Wi-fi passphrase with your own. The output will be piped to tee which then write to /etc/wpa_supplicant.conf file.
wpa_passphrase your-ESSID your-passphrase | sudo tee /etc/wpa_supplicant.conf

Now connect to wireless access point.
wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlan0

Obtain IP address:
dhclient wlan0

source, + how to auto-connect on boot
https://www.linuxbabe.com/command-line/ ... supplicant

very nice alternate method, using wpa command-line tool:
https://askubuntu.com/a/833894

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3932
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Command To Connect to Default Wifi?

Post#9 by ncmprhnsbl » 31 Aug 2018, 23:06

johnywhy wrote:
31 Aug 2018, 16:58
gentler way is:
# systemctl stop NetworkManager
johnywhy wrote:
31 Aug 2018, 16:58
disable network manager at boot:
systemctl disable NetworkManager
just pointing out: these are systemd commands that won't work with porteus ;)
porteus(Slackware) uses sysvinit/bsd style init scripts
so:

Code: Select all

# /etc/rc.d/networkmanager stop
and to disable at boot:

Code: Select all

# chmod -x /etc/rc.d/networkmanager
or simply rm
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#10 by johnywhy » 01 Sep 2018, 05:55

thx ncmprhnsbl! I updated my instructions, above.
ncmprhnsbl wrote:
31 Aug 2018, 23:06
or simply rm
Did you mean:

Code: Select all

rm  /etc/rc.d/networkmanager

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3932
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Command To Connect to Default Wifi?

Post#11 by ncmprhnsbl » 01 Sep 2018, 06:34

yeah, i got lazy.. ;p
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#12 by johnywhy » 01 Sep 2018, 08:55

i'm getting:

Code: Select all

# chmod -x /etc/rc.d/networkmanager
chmod: cannot access '/etc/rc.d/networkmanager': No such file or directory
this gives no error:

Code: Select all

# chmod -x /etc/rc.d/rc.networkmanager
on boot, NetworkManager isn't running :happy62:
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3932
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Command To Connect to Default Wifi?

Post#13 by ncmprhnsbl » 01 Sep 2018, 13:37

oops, yes, rc.networkmanager :oops:
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Command To Connect to Default Wifi?

Post#14 by johnywhy » 01 Sep 2018, 16:32

wifi-radar gives:

Code: Select all

# wifi-radar
Traceback (most recent call last):
  File "/usr/bin/wifi-radar", line 39, in <module>
    import gtk
ImportError: No module named gtk
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
Ed_P
Contributor
Contributor
Posts: 8359
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Command To Connect to Default Wifi?

Post#15 by Ed_P » 01 Sep 2018, 16:48

Code: Select all

guest@porteus:~$ su
Password: 
root@porteus:/home/guest# wifi-radar
bash: wifi-radar: command not found
root@porteus:/home/guest# /usr/bin/wifi-radar
bash: /usr/bin/wifi-radar: No such file or directory
root@porteus:/home/guest# 
Ed

Post Reply