Command to print name of SSID to which I am connected
Solution 1
How about iwgetid
? The iwgetid(8) man page says:
iwgetid is used to find out the NWID, ESSID or AP/Cell Address of the wireless network that is currently used.
Solution 2
This may work:
/sbin/iwconfig wlan0 | grep ESSID
Solution 3
None of the programs recommended in the previous answers was already installed on my system. However, iw
was. Therefore,
iw dev
does the trick. And if you really want just the ssid (e.g. for a script)
iw dev | grep ssid | awk '{print $2}'
works for me.
Related videos on Youtube
Tam Borine
Updated on September 18, 2022Comments
-
Tam Borine over 1 year
Is there a simple command to find out to which Wi-Fi AP I am connected?
I have several networks configured in my
/etc/wpa_supplicant.d/wpa_supplicant.conf
, with assigned priorities, and depending where I am I connect to the best available Wi-Fi/SSID. Connection happens automatically, so I don't know to which SSID I am connected.Now I need to check (inside a script) whether I am connected at home, or somewhere else.
I know that I can list all available SSIDs with
iwlist wlan0 scan
But how can I print the SSID to which I am connected at the moment?
I am using Debian.
-
Tam Borine over 9 years
iwgetid wlan0 --raw
is exactly what I was looking for. Thanks. -
Unix almost 4 yearsWhat system are you using, in what version?
-
Fenhl about 3 yearsFrom what I've seen so far, if the computer doesn't have Wi-Fi configured,
iwgetid
may not be installed, so that is something you may want to check first. And then if it is installed but not connected,iwgetid --raw
will output nothing and exit with status code 255.