Marcio Cunha

How to Find Saved Wi-Fi Passwords on Your Computer Using the Terminal

Learn how to retrieve wireless network keys stored on Windows, macOS, and Linux using only native terminal commands without installing extra software.

Marcio Cunha8 min
Also available in:EspañolPortuguês
Summary
  • Modern operating systems store wireless network credentials in local databases protected by user access privileges.
  • Command prompt and PowerShell utilities allow direct extraction of previously connected Wi-Fi profiles on Windows systems.
  • Command-line tools in Linux rely on network management daemons to reveal plaintext configuration files.
  • The macOS ecosystem maintains access keys within the system keychain utility, accessible via terminal with administrator rights.
  • Auditing saved connections helps troubleshoot connectivity failures and remove obsolete profiles that compromise machine security.

Introduction to Stored Network Profiles

When connecting a computer to a wireless network, the operating system automatically stores the network name, known as SSID, alongside its respective security key. This convenience prevents users from having to retype the password every time the device restarts or moves around the workspace. In practice, this means such information gets recorded in local configuration files or system registry hives. In many everyday situations, such as when connecting a new device and forgetting the credential, querying this internal database becomes the fastest solution.

Recovering this information does not require installing third-party software or complex security auditing tools. Operating systems themselves provide command-line interfaces capable of listing, filtering, and displaying confidential data stored in persistent storage. To execute these procedures successfully, however, possessing administrator or superuser privileges on the machine is fundamental, as access to network credentials is strictly restricted for data protection and privacy reasons.

Extracting Credentials in Windows Environments

In the Windows operating system, the most prominent command-line interface for managing wireless network adapters is a utility called Netsh, short for Network Shell. In practice, this program acts as a text-based control panel that interacts directly with the system's network protocol stack. To view all networks saved on the computer, we open the Command Prompt or PowerShell and execute the profile listing command.

The specific command to list saved networks is:

netsh wlan show profiles

After identifying the exact network name from the generated list, the next step consists of requesting complete details for that specific profile, including the security key in legible text. For this purpose, we use the clear key display parameter. In practice, this reveals the encrypted secret that remained hidden within the traditional graphical interface.

The command to reveal the network password is:

netsh wlan show profile name='NetworkName' key=clear

Within the terminal output, the user should look for the field labeled Key Content, which displays the exact text of the password configured for that connection.

Recovering Wi-Fi Passwords on Linux

The Linux ecosystem features diverse distributions and approaches for managing network connections, with NetworkManager being the most common service on personal computers. In practice, this service centralizes wired and wireless network configurations, storing sensitive information in text files located within the system directory. These files contain detailed metadata about each access point the computer has successfully connected to.

To locate these configuration files and read the stored password, we navigate to the corresponding directory and use standard reading commands like cat. Because these files contain confidential access data, the operation requires using the sudo command to elevate execution privileges. In practice, the configuration file stores the password in plaintext within the section dedicated to wireless security.

The typical terminal workflow involves the following commands:

cd /etc/NetworkManager/system-connections/sudo cat NetworkName.nmconnection

Within the displayed content, the term psk followed by an equals sign reveals the exact password used in the WPA or WPA2 authentication of that specific network.

Accessing Network Keys on macOS

In the macOS operating system developed by Apple, the management of passwords and cryptographic keys is centralized in a subsystem called Keychain. In practice, this secure repository protects website passwords, digital certificates, and Wi-Fi network credentials using master keys linked to the user account. To interact with this database through the command line, we utilize the security utility.

The basic command to extract the password of a specific wireless network requires indicating the network name and explicit authorization to display the secret in readable text. When executed, the terminal may prompt for the machine administrator password to release access to the protected keychain vault. In practice, this barrier prevents malicious applications from reading saved credentials without the physical or digital consent of the owner.

An example command used in the macOS terminal is:

security find-generic-wlan-password -s 'NetworkName' -g

The -g parameter instructs the system to retrieve the stored secret and print it directly to the screen after validating the user credentials.

Security Considerations and Best Practices

Discovering Wi-Fi passwords via the terminal highlights the importance of keeping physical and logical computer access strictly protected. Anyone with command-line access and administrative privileges can extract corporate or residential network keys stored in the machine history. In practice, this reinforces the need to use robust screen lock passwords and never leave the computer unlocked in public or shared environments.

Another relevant point concerns the periodic cleaning of old or unknown network profiles. Keeping obsolete connections accumulated in the system not only consumes space in internal registries but also expands the exposure surface should a security incident occur. By understanding how the system manages these credentials, technical autonomy is gained to diagnose problems and ensure a more transparent and controlled network operation.