Forgot your home Wi-Fi password, but you're connected to the router on a Linux laptop? Don't rush to reset your router or call your ISP. Most Linux distributions—from Ubuntu And Debian to Arch Linux And Fedora Saved network passwords are stored in system files and can be retrieved without special programs. The main thing is to know where and how to look for them.
In this article we will look at 5 ways getting a Wi-Fi password on Linux: via the terminal (using nmcli, iwconfig and manual reading of configs), as well as graphical methods for users GNOME, KDE Plasma and other DE. We will separately dwell on the nuances of working with encrypted networks (WPA/WPA2) and explain why some methods may not work on recent versions of distributions. Whether you're an admin or just an inquisitive user, you'll find answers to all your questions here.
1. Method: Use nmcli — a universal method for NetworkManager
Utility nmcli (NetworkManager Command Line Interface) is the standard network management tool in most modern distributions. It allows you to not only connect to Wi-Fi but also retrieve saved passwords. This method works in Ubuntu, Fedora, Linux Mint and other systems with NetworkManager.
To find out the password:
- Open Terminal (
Ctrl+Alt+T). - List saved networks:
nmcli -s -g NAME connection show - Copy the name of the desired network (for example,
MyHomeWiFi). - Get your password:
nmcli -s -g 802-11-wireless-security.psk connection show "MyHomeWiFi"
If the command returned an empty line, check:
- 🔹 Are you connected to this network? Now (some distributions do not save passwords for "foreign" networks).
- 🔹 Is it used?
NetworkManager(check with commandps aux | grep NetworkManager). - 🔹 Have the access rights to the config been changed? (
ls -la /etc/NetworkManager/system-connections/).
Method 2: Reading NetworkManager configuration files manually
All saved networks and their passwords are stored in configuration files at the path /etc/NetworkManager/system-connections/This method is suitable if nmcli for some reason it doesn't work or you prefer "manual" control.
Instructions:
- Open a terminal with privileges
root:sudo -i - Go to the directory with configs:
cd /etc/NetworkManager/system-connections/ - View the list of files (each file = one network):
ls - Open the file you need (for example,
nano MyHomeWiFi.nmconnection) and find the line:psk=your_password
Example of file content:
[connection]id=MyHomeWiFi
type=wifi
[wifi]
ssid=MyHomeWiFi
mode=infrastructure
[wifi-security]
key-mgmt=wpa-psk
psk=12345678[ipv4]
method=auto
What to do if there are no files in the folder?
If the directory /etc/NetworkManager/system-connections/ empty, this means that:
1) You are using a different network manager (eg. wpa_supplicant or connman).
2) Access rights are limited (try sudo ls -la /etc/NetworkManager/).
3) The network is connected in "guest" mode without saving the password.
⚠️ Attention: Do not edit these files manually unless you are confident in the syntax! Errors in the configuration may result in loss of connection to the network. For changes, use nmtui or graphic settings.
3. Method: Use wpa_supplicant for systems without NetworkManager
Some distributions (eg. Arch Linux or minimalist assemblies) are used wpa_supplicant instead of NetworkManagerIn this case, passwords are stored in a file /etc/wpa_supplicant/wpa_supplicant.conf.
To extract the password:
- Open the config with superuser rights:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf - Find the network block (example):
network={ssid="MyHomeWiFi"
psk="12345678"
key_mgmt=WPA-PSK
}
If the file is empty or does not exist:
- 🔹 Check alternative routes:
/etc/wpa_supplicant.confor~/.config/wpa_supplicant/. - 🔹 Make sure that
wpa_supplicantis actually used (commandps aux | grep wpa). - 🔹 In some cases, passwords are stored in encrypted form (see the section about
wpa_passphrase).
4. Method: Graphical interface (GNOME, KDE, XFCE)
If you prefer not to use the terminal, most graphical desktop environments have built-in password viewing tools. Let's look at options for popular desktop environments.
GNOME (Ubuntu, Fedora Workstation):
- Open
Settings → Wi-Fi. - Click on the gear next to the network name.
- In the section
Securitycheck the boxShow password.
KDE Plasma:
- Go to
System Settings → Network. - Select your Wi-Fi network and click
Change. - Tab
Security→Show password.
XFCE (Linux Mint XFCE, Xubuntu):
- 🔹 Open
Network Manager(tray icon). - 🔹 Select a network →
Properties→Show password.
⚠️ Attention: In some distributions (for example, Ubuntu 22.04+) the graphical interface can do not show password Due to security policy, please use terminal methods in this case.
Make sure you are connected to the correct network
Make sure your account has permission to view passwords.
Please update your network manager (eg. sudo apt update && sudo apt upgrade network-manager)
Restart your computer if the network does not appear in the list.
-->
5. Method: Alternative utilities (iwconfig, wpa_passphrase)
If standard methods don't work, try specialized utilities. They require more knowledge, but can sometimes save lives in unusual situations.
1. iwconfig (for current connection only):
This command shows information about the current Wi-Fi connection, but does not display the passwordHowever, it is useful for diagnostics:
iwconfig wlan0
If there is a line in the output Access Point: XX:XX:XX:XX:XX:XX, then you are connected to the network, and the password can be extracted in other ways.
2. wpa_passphrase (to generate a hash):
This utility does not show saved passwords, but it allows you to generate a hash for a new connection. Useful if you know the password and want to encrypt it for the config:
wpa_passphrase "MyHomeWiFi" "12345678"
3. cat /proc/net/wireless:
Shows wireless connection statistics, but does not contain passwordsUse to check signal strength and connection errors.
| Utility | Shows password? | When to use |
|---|---|---|
nmcli |
✅ Yes | Main method for NetworkManager |
Configs NetworkManager |
✅ Yes | If nmcli doesn't work |
wpa_supplicant.conf |
✅ Yes | For systems without NetworkManager |
| Graphical interface | ⚠️ Sometimes | For GNOME/KDE users |
iwconfig |
❌ No | For diagnostic purposes only |
Common mistakes and their solutions
Even experienced Linux users sometimes encounter problems when trying to extract a Wi-Fi password. Here are the most common errors and how to fix them:
1. "Permission denied" when accessing configs:
- 🔹 Use
sudoin front of the teams. - 🔹 Check file ownership:
sudo chown $USER:$USER /etc/NetworkManager/system-connections/*
2. Configuration files are encrypted:
In some distributions (for example, Fedora with it turned on SELinux) passwords may be stored in encrypted form. To read them, temporarily disable SELinux (not recommended for continuous use):
sudo setenforce 0
3. The network is connected, but the password is not saved:
If you connected to the network via "guest" mode or wpa_supplicant without a flag -w, the password may not be saved. Solution:
- 🔹 Reconnect to the network with a tick
Save password. - 🔹 Check your settings
NetworkManager:sudo nano /etc/NetworkManager/NetworkManager.confMake sure the line
store-passwords=truenot commented.
FAQ: Answers to frequently asked questions
Is it possible to find out the password for a Wi-Fi connection I've connected to before but am not connected to now?
Yes, if the password was saved in the system. Use nmcli or check the files in /etc/NetworkManager/system-connections/However, some distributions (for example, Tails OS) automatically delete passwords after disabling.
I changed the password on my router, but Linux still connects with the old one. Where is it stored?
This means the system has an outdated password. Update it:
- Remove the old connection:
nmcli connection delete "MyHomeWiFi" - Reconnect to the network (enter the new password).
Is it safe to store Wi-Fi passwords in plain text in config files?
By default, files in /etc/NetworkManager/system-connections/ available only to the user rootThe risk is minimal, but to increase safety:
- 🔹 Set strict permissions:
sudo chmod 600 /etc/NetworkManager/system-connections/* - 🔹 Use
wpa_supplicantwith encryption of configs.
How do I find my Wi-Fi password on Linux if I'm connected via Ethernet?
If you are connected to the router via cable but want to know its Wi-Fi password, use:
- The router's web interface (usually
192.168.1.1or192.168.0.1). - Command for viewing saved networks (if previously connected via Wi-Fi):
nmcli -g NAME,802-11-wireless-security.psk connection show
Do these methods work on Linux for Android (Termux)?
Partially. In Termux can be used termux-wifi-connectioninfo, but to access system passwords you need root rightsWithout them, it will be impossible to extract the password due to Android security restrictions.