If you are working on a headless Linux server or utilizing a minimal desktop environment, you do not have the luxury of glancing at a colorful weather widget on your taskbar. Opening a bulky web browser like Firefox simply to check the forecast is an incredibly inefficient use of your system’s resources.
Fortunately, you can check the weather for any city in the world directly from the command line in under three seconds. You do not need to install complex third-party weather applications, nor do you need to register for API keys. You simply need the standard curl command and a brilliant open-source service called wttr.in.
The Essential Command: curl wttr.in
The curl command is a core Linux utility designed to transfer data from a URL. While it is usually used to download software packages, it can also pull raw text from specific websites directly into your terminal screen.
A developer created wttr.in, a weather service specifically designed to output its data in beautifully formatted, ASCII-art text rather than standard HTML.
- Open your terminal application.
- Type the following command and press Enter:
curl wttr.in
The terminal will instantly print a stunning, three-day weather forecast. It will use your server’s current IP address to automatically determine your city, and it will display the current temperature, wind speed, precipitation chance, and an ASCII-art depiction of the sun or clouds.
How to Check the Weather for a Specific City
If you are connected to a remote server located in Germany, but you want to know the weather outside your house in New York, the default command will fail (it will show the weather in Germany). You must append the specific city name to the end of the URL.
curl wttr.in/NewYork
(Note: You should remove the spaces from multi-word city names, or use an underscore, e.g., New_York).
You can also use airport IATA codes if you want extreme precision. For example, to check the weather specifically at London Heathrow Airport, you would type:
curl wttr.in/LHR
How to Customize the Output (Moon Phases and Compact Modes)
The standard three-day forecast takes up a massive amount of vertical space on your terminal screen. If you only want to know what the weather is doing exactly right now, you can pass specific parameters to the URL.
The One-Line Format
If you only want a single line of text detailing the current conditions (perfect for adding to a server MOTD or a custom bash prompt), append ?format=3 to the command.
curl wttr.in/London?format=3
This will output a simple string: London: ⛅️ +14°C
Checking the Moon Phase
If you are planning an astrophotography session or a nighttime hike, you can actually use the service to render an accurate ASCII depiction of the current lunar phase.
curl wttr.in/Moon
Troubleshooting: Command Not Found
If you type the command and the terminal returns an error stating bash: curl: command not found, it means your specific Linux distribution is so minimalist that it did not include the curl utility by default.
You can install it in five seconds using your package manager.
- On Debian/Ubuntu: Type
sudo apt install curl - On CentOS/RHEL: Type
sudo yum install curl
Once installed, the weather command will work flawlessly.