NetworkManager comes with a CLI (command line interface) function called nmcli.
If you have networkmanager then you probably also have nmcli - if not; you can install it.
When you first connect to your Wi-Fi you have the password from your ISP and then......you forget it!
So when your brother comes to visit and wants to hook up his iPhone to your wifi - you can't help him
Well you could call your ISP and stand on your head to get the password again (or find it in GUI), but there is a better way:
Find your connection with:
Code: Select all
nmcli device
this will show something like this:
Code: Select all
DEVICE TYPE STATE CONNECTION
docker0 bridge connected docker0
wlp2s0 wifi connected Wi-Fi connection 1
We are interested in the Wi-Fi connection name for wifi - in this case it is "Wi-Fi connection 1"
Once we have established that; we can reveal all the secrets of that connection - including password with:
Code: Select all
nmcli --show-secrets connection show "Wi-Fi connection 1"
The password will be on a line called something like 802-11-wireless-security.psk
It is that easy.
Of course you will never remember this command so why not make an alias - like this:
Code: Select all
alias wifisecrets='nmcli --show-secrets connection show "Wi-Fi connection 1"'
Or maby make it password specific;
Code: Select all
alias wifipassword='nmcli --show-secrets connection show "Wi-Fi connection 1" |grep 802-11-wireless-security.psk'
Now you can simply type wifipassword in a terminal and there it is
Time for me to reveal a little secret in the end:
This is not limited to wifi