How to View a WiFi Password in Linux: Instructions

It's quite common to need to find out the password for a wireless network to which your laptop or PC is already connected. In kernel-based operating systems Linux This task is quick, but requires knowledge of specific commands or paths to configuration files. Unlike Windows graphical interfaces, where everything is hidden behind buttons, Linux offers transparent access to system data.

There are several basic methods of extraction security keys: via the environment's graphical interface, via the command line, or by directly reading configuration files. The choice of method depends on the distribution you're using and whether you have a graphical interface installed. System administrators often prefer console-based utilities for their versatility.

It is important to understand that you will need permissions to perform most operations. superuser (root)Without the appropriate privileges, the system will not allow reading files containing sensitive network connection information. This is a basic security mechanism that protects data from unauthorized access, even within the local system.

Using NetworkManager in the GUI

Most modern distributions, such as Ubuntu, Fedora or Linux Mint, use NetworkManager to manage network connections. If you work in a graphical environment (GNOME, KDE, XFCE), you can find the password through the standard system settings, without resorting to complex commands.

To do this, you need to open the network settings, select the desired connection, and go to the security settings. However, the path may differ depending on desktop environmentFor example, in GNOME, this is done through the "Wi-Fi" menu, then the settings button for a specific connection, and the "Security" tab.

  • 🔍 Find the network icon in the system tray and open settings.
  • 🔒 Go to the "Security" tab in the network properties.
  • 👁️ Toggle the "Show password" switch.

The system may ask you to confirm your identity by entering your user password or fingerprint. This protects you from other users accidentally viewing sensitive data on your computer. After confirmation WPA/WPA2 key will be displayed in the text field in open form.

⚠️ Note: In some enterprise Linux distributions, security policies may block password display even for administrators. In this case, the graphical method will not work, and you will have to use the terminal.

If you're using KDE Plasma, the process is slightly different: open "System Settings," find the network section, select your connection, and click "Wireless Settings." There will also be a checkbox to display the saved key.

Viewing a password through the terminal with nmcli

For those who prefer command line, utility nmcli (NetworkManager command line interface) is a powerful tool. It allows you to manage your network and obtain complete information about connections, including hidden passwords if you have root privileges.

The first step is to find your connection name. This is often the same as your network name (SSID), but may differ if you've renamed profiles previously. Enter the following command to list all known connections:

nmcli connection show

In the resulting list, find the desired network and copy its name. Next, use the command to display all the parameters of a specific connection. This is where the information you're looking for is hidden in the field. secrets.

sudo nmcli connection show "Your_Connection_Name" | grep 802-11-wireless-security.key-mgmt

However, to see the password itself, you need to request a display of the secret data. The command should look like this, where the actual name from the list is substituted for the name:

sudo nmcli -s -g 802-11-wireless-security.key-mgmt connection show "Connection_Name"
📊 What is your preferred method for entering commands?
Copying from the clipboard
Manual typing
Using aliases
GUI only

Please note that the command output may not be obvious to a beginner. If the encryption method is WPA-PSK, the password will be displayed after executing the command with the flag. -g (get values) for the field wireless-security.key-mgmt or a similar secret parameter.

Working with wpa_supplicant configuration files

On systems that do not use NetworkManager, or on server versions of Linux (Debian, Raspbian), a daemon is often responsible for wireless connections. wpa_supplicantThe configuration is stored in a text file that can be read directly.

The main configuration file is usually located at /etc/wpa_supplicant/wpa_supplicant.confIt contains blocks inside. network for each stored network. Passwords can be stored in cleartext or as a PSK hash.

Parameter Description Example of meaning
ssid Network name (SSID) "HomeWiFi"
psk Password in clear text "mypassword123"
proto Security protocol RSN
key_mgmt Key management method WPA-PSK

If the password is stored as a hash (a long 64-character string), it won't be possible to recover the original text by simply viewing the file. The hash is generated from the password and SSID. However, if you see the field psk="text", then you're in luck - the password is clearly specified.

To view the contents of a file, use the command cat or a text editor nano with superuser rights:

sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
What to do if the file is missing?

The wpa_supplicant.conf file may be missing if your system uses a different network manager, such as systemd-networkd or ConnMan. In this case, look for the configuration in /etc/netplan/ or /etc/connman/.

Extracting keys from NetworkManager connection files

NetworkManager stores connection profiles in a directory /etc/NetworkManager/system-connections/Each profile is a separate file with the extension .nmconnection or without extension, containing all parameters, including passwords.

By default, these files are read-only for the root user. To view the password, open the corresponding file with a text editor. First, let's list the files in the directory to find the one we need:

sudo ls /etc/NetworkManager/system-connections/

Then we open the file using cat or nanoThe password you are looking for is in the section [wifi-security] under the parameter psk.

sudo cat /etc/NetworkManager/system-connections/"FileName".nmconnection
  • 📂 The directory contains files of all networks ever saved.
  • 🔐 Files have strict permissions (chmod 600).
  • 📝 The password is in the line psk=your_password.

This method is especially useful if the GUI is frozen or not working. You get direct access to the raw configuration data. Be careful when editing these files manually, as a syntax error can result in an inability to connect.

⚠️ Note: The file structure in /etc/NetworkManager/system-connections/ may vary depending on the version of NetworkManager. Newer versions (1.x and higher) use the keyfile format, while older versions use an ini-like format. Always check the contents before editing.

Alternative methods and utilities

There are other ways to access saved data, especially if the standard paths don't work. For example, in distributions based on Arch Linux or when using systemd-networkd, the configuration can be stored in /etc/systemd/network/ or controlled through wpa_passphrase.

You can also use the utility grep To quickly search for password strings in all configuration files at once. This saves time if you don't remember the exact file name or path.

sudo grep -r "psk=" /etc/NetworkManager/system-connections/

This command will recursively iterate through all files in the directory and output lines containing "psk=". The result will contain the file name and the password itself, which is very convenient for quick searching.

Another option is to use specialized scripts such as wifi-password (available in some distributions' repositories) that automatically detects an active connection and prints the password with a single command.

Security and Access Recovery

Understanding where passwords are stored is important not only for recovering them, but also for ensuring cybersecurityIf an attacker gains physical access to your computer and root privileges, they can steal all saved networks.

Therefore, it's crucial to set strong login passwords and use disk encryption (such as LUKS). This will protect configuration files from being read when booting from a Live USB or other media.

  • 🛡️ Use home directory encryption.
  • 🔒 Restrict access rights to configuration files.
  • 🔄 Regularly change passwords for important WiFi networks.

If you've forgotten your router password and it's not saved on any devices, your only option is to reset the router to factory settings. However, if at least one Linux computer has ever connected to the network, the chances of regaining access are very high.

☑️ WiFi Security Check

Completed: 0 / 4

Frequently Asked Questions (FAQ)

Is it possible to find out the password if I have never connected to this network from this PC?

No, Linux (like any other OS) can't crack passwords on the fly. It can only reveal the data stored in the system upon a successful connection. Other tools (such as aircrack-ng) exist for password cracking, but they require specialized equipment and knowledge.

Where is the password stored on Android running Linux?

On Android, passwords are also stored in wpa_supplicant files, but access to them is restricted. Root access and access to the /data/misc/wifi/wpa_supplicant.conf section are required. Without root access, viewing saved passwords using standard tools is impossible.

What if the password in the configuration file is hashed?

If you see a 64-character .hex code instead of text, it's a hash. Recovering the original password from a hash using Linux tools is impossible (it's a one-way function). However, you can use this hash to connect by copying it into the password field if the interface allows entering hex keys, or generate a new password using wpa_passphrase.

Is it safe to store passwords in text files?

This is the default behavior of most operating systems for convenient automatic connection. Security is ensured by access rights (root only) and disk encryption. If your disk is encrypted and the computer is offline, files are inaccessible. When the computer is on, the risk depends on the physical security of the device.

In conclusion, managing network connections in Linux gives the user complete control over their data. Knowing where to find configuration files and which commands to use will ensure you never lose internet access due to a forgotten password.