How to Check the Weather from the Linux Terminal Using curl

When you are working deep inside the Linux terminal, opening a bloated graphical web browser just to check if you need an umbrella can severely disrupt your workflow. While there are dedicated weather applications you can install via your package manager, there is a much faster, geekier way to get a full weather forecast directly in your command line.

By using the standard curl command combined with a powerful open-source service called wttr.in, you can pull a beautifully formatted, text-based weather report directly into your terminal without installing any new software.

The Basic Command

The curl command is a standard tool used to transfer data from or to a server. Almost every Linux distribution comes with it pre-installed. The service wttr.in detects that a terminal is accessing it and formats its web page using ANSI escape codes to render colourful ASCII art.

To get the current weather for your current location (determined automatically by your public IP address), simply open your terminal and type:

curl wttr.in

Press Enter. Within a second, the terminal will print a stunning three-day forecast featuring ASCII clouds, suns, or rain, alongside exact temperatures, wind speed, and precipitation chances.

How to Check the Weather for a Specific City

If you are travelling or want to check the weather for a remote server location, you can append a city name to the URL. If the city name consists of multiple words, you must replace the spaces with plus signs (+) or enclose the URL in quotation marks.

curl wttr.in/London

curl "wttr.in/New+York"

You can even check the weather for a specific airport by using its three-letter IATA code, preceded by a tilde (~). For example, to check the weather at London Heathrow:

curl wttr.in/~LHR

Customising the Output

The default output of wttr.in is quite large, taking up a significant portion of your terminal screen. If you prefer a minimalist approach, the service allows you to pass formatting parameters.

The One-Line Forecast

If you want to add the current weather to your bash prompt (PS1) or a system monitoring dashboard (like tmux), you can request a single, concise line of output by using the ?format parameter.

curl wttr.in/?format=3

This command will output a single line containing the city name, a small weather emoji, and the current temperature (e.g., “London: ☁️ +15°C”).

Removing the ASCII Art

If you want the full forecast data but find the ASCII graphics distracting, you can strip them away using the ?0 parameter.

curl wttr.in/?0

Changing the Units (Celsius vs. Fahrenheit)

By default, wttr.in attempts to guess your preferred units based on your geolocation. If it guesses incorrectly, you can force the metric or imperial system.

  • To force Metric (Celsius and km/h), append ?m: curl wttr.in/Chicago?m
  • To force US Customary (Fahrenheit and mph), append ?u: curl wttr.in/Paris?u

Creating an Alias for Easy Access

If you find yourself using this tool frequently, typing out the URL every time can become tedious. You can create a bash alias to reduce the command to a single word.

Open your ~/.bashrc file in a text editor (like nano) and add the following line to the bottom:

alias weather='curl wttr.in'

Save the file and run source ~/.bashrc. From now on, you simply type weather into your terminal, press Enter, and instantly receive your local forecast.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.