The Linux command shell is your fastest way to see what networks your system is connected to, whether it’s Wi-Fi, Ethernet, or even VPN links. Run these simple commands to list active connections, check signal strengths, and troubleshoot connectivity issues without opening GUI apps. This works on most modern Linux distributions (Ubuntu, Fedora, Arch, etc.) and macOS Terminal, though exact syntax varies slightly by OS.

What You'll Need

  • Access to a terminal (Command Prompt on Windows, Terminal on macOS/Linux).
  • Basic knowledge of command-line shortcuts like tab for autocompletion.
  • Administrator privileges may be required for advanced checks (e.g., ifconfig or ip on older systems).
  • A modern Linux distribution or macOS system with networking tools installed (usually pre-installed).
  • For Windows users: Windows Terminal or PowerShell (see Frequently Asked Questions for alternatives).

Step-by-Step

  1. List active network interfaces

    Run this command to see all network adapters your system recognizes, including Wi-Fi, Ethernet, and virtual interfaces like VPNs.

    • Linux (modern distros: Ubuntu 22.04+, Fedora, Arch): ip link or ifconfig -a (older systems). Hold Ctrl+Alt+T to open the terminal.
    • macOS: networksetup -all lists all adapters, or use ifconfig for detailed stats.
    • Windows (Command Prompt/PowerShell): ipconfig /all (shows only physical adapters) or netsh interface ipv4 show interfaces (more detailed).

    Example output: 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 3: wlan0: mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 54:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

    Note: Wi-Fi interfaces often start with wlan (Linux/macOS) or Wi-Fi (Windows). Ethernet is typically eth0 or enp3s0.

  2. Check Wi-Fi networks (signal strength + neighbors)

    To see nearby Wi-Fi networks and your current connection details, use:

    • Linux/macOS: iw list (lists available networks) or iw dev wlan0 scan (scans for neighbors). For your active connection, run: iw dev wlan0 link (Linux) or networksetup -showall Wi-Fi (macOS).
    • Windows: Use PowerShell: Get-NetIPAddress -InterfaceAlias "Wi-Fi" | Select-Object InterfaceAlias, IPAddress, InterfaceDescription To scan for nearby SSIDs (requires admin): netsh wlan show networks then netsh wlan connect name="SSID".

    Example (Linux): [sudo] password for youruser: wlan0: interface Iface, chipset Qualcomm Atheros QCA9377 supported channels: 1-14 52-140 MHz supported rates: 1-100 Mbps SSID: "MyHomeWiFi" (BSSID: 00:11:22:33:44:55) signal: -30 dBm

  3. View active connections (TCP/UDP ports)

    To see what apps are using ports (useful for troubleshooting), run:

    • Linux/macOS: lsof -i (lists open network sockets) or ss -tulnp (shows TCP/UDP ports + PID).
    • Windows: Use Process Explorer (from Microsoft Sysinternals) or: netstat -ano (shows active connections by process ID). Filter for specific ports with netstat -ano | findstr "PORT".

    Example (Linux): COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 1234 root 12u IPv4 12345 0t0 TCP *:ssh (LISTEN) nginx 5678 www-data 33u IPv4 45678 0t0 TCP localhost:80 (LISTEN)

  4. Test connectivity to networks

    Verify if a network (e.g., a remote server or local IP) is reachable:

    • Ping test: ping google.com (Linux/macOS/Windows) or ping -c 3 google.com (3 pings).
    • Advanced: traceroute Linux/macOS: traceroute google.com Windows: tracert google.com (Shows hops from your router to the target.)

Common Mistakes

  • Using the wrong interface: If you run ifconfig but only lo (loopback) appears, your system isn’t connected to a physical network. Check with ip a or ifconfig -a to confirm Wi-Fi/Ethernet is active.
  • Admin privileges denied: Tools like iw or netsh may require sudo. Add sudo before the command (Linux/macOS) or try the command in an elevated PowerShell terminal (Windows).
  • Ignoring timezone/locale issues: On Linux, commands like iw may show incorrect signal strength if the system’s locale isn’t set to UTF-8. Fix with: export LANG=en_US.UTF-8 before running the command.
  • Mixing Linux/macOS commands on Windows: Windows’ ipconfig behaves differently from Linux’s ip or ifconfig. Stick to Windows-native commands unless you’re using WSL (Windows Subsystem for Linux).

Tips

  • Save output to a file: Redirect commands to a file for later analysis. Example: iw dev wlan0 link > network_status.txt (Linux).
  • Monitor changes over time: Use watch -n 1 (Linux) or ping google.com repeatedly to see if network metrics fluctuate.
  • Wi-Fi signal strength: On Linux, iw dev wlan0 link shows signal strength in dBm (lower = weaker). On macOS, use networksetup -getinfo Wi-Fi for details.
  • Windows alternative: PowerShell: For more advanced networking, explore WMI (Windows Management Instrumentation) with Get-WmiObject Win32_NetworkAdapterConfiguration.
  • GUI fallback: If commands fail, use the system’s built-in network settings (e.g., Ubuntu’s NetworkManager GUI or macOS System Preferences).

Troubleshooting

If commands return no results or show errors, start with these checks:

  1. Restart networking

    On Linux/macOS: sudo systemctl restart NetworkManager (Ubuntu) or sudo systemctl restart NetworkManager.service (Fedora). On Windows: netsh interface reset in an admin Command Prompt.

  2. Update tools

    Ensure your system and tools are up to date. For Linux, run: sudo apt update && sudo apt upgrade (Debian/Ubuntu) or: sudo pacman -Syu (Arch). Check for macOS updates in System Settings.

  3. Check service status

    If iw or netsh fails, verify the network services are running: sudo systemctl status NetworkManager (Linux). On Windows, check services.msc for "Network Connections."

  4. Reinstall tools

    If commands persistently fail, reinstall the tool: sudo apt reinstall ifconfig iputils-ping (Linux) or reinstall macOS utilities via Software Update.

  5. Verify Wi-Fi is enabled

    On macOS, right-click the Wi-Fi icon in the menu bar and ensure "Wi-Fi" is turned on. On Linux, check iw dev—if no Wi-Fi interfaces appear, toggle Wi-Fi in your distro’s GUI settings.

  6. Alternative: Use GUI tools

    If CLI tools are unreliable, use the system’s native network manager (e.g., Ubuntu’s nmcli, macOS System Preferences, or Windows Network Settings). Avoid third-party tools unless they integrate with official APIs.

Frequently Asked Questions

How do I see my current IP address?

Run ip a (Linux/macOS) or ipconfig (Windows) and look for the inet lines under your active interface (e.g., wlan0 or Wi-Fi).

What if I don’t see my Wi-Fi adapter in the commands?

This usually means your Wi-Fi is disabled or unrecognized. Check with lsusb (Linux) to confirm a Wi-Fi chip is plugged in, or enable Wi-Fi in your distro’s GUI settings.

Can I check network traffic in real-time?

Yes! Use iftop (Linux) or Windows Performance Toolkit (Windows) to monitor bandwidth usage per connection. Install iftop with sudo apt install iftop (Debian).

Why does ping say "Request timed out" when the network is connected?

This often means your device is blocking ICMP (ping) requests. Try traceroute or check if ICMP is disabled in your firewall (Linux: sudo ufw allow in 8 for ICMP).

How do I find my router’s IP address?

On Linux/macOS: Run arp -a and look for your local IP. On Windows: Use arp -a or ipconfig /all. Your router’s IP is usually 192.168.1.1 or 10.0.0.1.

Is there a way to see which apps are using the internet?

Use lsof -i (Linux) or netstat -ano (Windows) to list active connections. For macOS, use netstat -vn.