How To Check Weather Details From Command Line In Linux
Have you ever wondered how to find the weather details of your home town from command line in Linux without installing any additional software/applications? No? No problem. It is easier than you think! You don’t have to install any extra utilities. We can just use the‘curl’ command, which is installed by default in most Linux and Unix distributions, to display the weather details right from the Terminal itself.
If Curl is not installed, you can install it as shown below depending upon the Linux distribution you use.
On Arch Linux and its derivatives:
$ sudo pacman -S curl
On Debian / Ubuntu / Linux Mint:
$ sudo apt-get install curl
On RHEL / CentOS / Fedora:
$ sudo yum install curl
$ sudo dnf install curl
$ sudo zypper in curl
Check Weather Details From Command Line In Linux and Unix
Now, let us see how to check weather details from command line using wttr.in utility with curl command. The wttr.in is a web front-end for a utility called Wego. Wego is a command line utility used to display the weather details of given location. Since wttr.in is a web-based utility, we don’t need to install it or any other additional utilities. We can get the weather details using wttr.in and curl either from command line or a web browser in no time.
Using wttr.in utility, we can display weather details,
- of the current location,
- of a particular location,
- of a geographical location,
- using domain name or IP address,
- using Zip code,
- using Airport code,
- of moon phase.
Let us see one by one.
Display weather details of current location
Open up your Terminal and run:
$ curl wttr.in
The above command will display the weather details of your current location based on your IP address.
Display weather details of a particular location
You can even get a particular region weather details. For example, to display the weather details of Erode, a small district in Tamilnadu state, India.
$ curl wttr.in/erode
Replace “Erode” with your home town name to get the weather details. This command should work on almost all Linux and Unix operating systems.
Display weather details for a geographical location
Some times you might want to know the weather details for a geographical location (for example mountain name, monument, or some special location) other than your town or a city. It is also possible. Say you want to display the weather details of a location where Tajmahal is located, just add the tilde symbol
~ before the name like below.
$ curl wttr.in/~Tajmahal
How about the weather details in Everest? Just run:
$ curl wttr.in/~Everest
Display weather details using domain name or IP address
You can also use domain name prefixed with ‘@’ as a location specificator.
$ curl email@example.com
As you see in the above output, ostechnix.com is located in Brea city, United States of America, hence the above command displays weather details of Brea city. You can also use IP address instead of domain.
Display weather details using Airport code
I know a particular Airport code. Can I able to get the weather details of that region? Yes!! For example, New Delhi Indira Gandhi International Airport code is DEL.
To display the weather details, just run:
$ curl wttr.in/DEL
Display weather details using Zipcode
It is also possible to get weather details if you know any region’s zipcode. For example, New York are a code is 10001. So, just run the following command to display the weather information of New York city.
$ curl wttr.in/10001
Display weather details in a web browser
Can I get the same details in a web browser? Of course, yes! Open up your web browser, and navigate to http://wttr.in/ in the address bar.
The developer has added a new feature to display the phase of moon.
$ curl wttr.in/moon
$ curl wttr.in/[email protected]
Change Weather units
By default the USCS units (United States Customary System Units) are used for the queries from the USA and the metric system for the rest of the world. You can, however, change Weather units by adding ?u or ?m to a URL like below:
$ curl wttr.in/Chennai?u
$ curl wttr.in/Chennai?m
To display the help section of wttr.in utility, run:
$ curl wttr.in/:help
And, that’s all for now. This is one of the easiest method ever I have found to display the weather details of any location. Have you tried this utility? What do you think about it? Do you know any other alternatives? Great! Feel free to let us know in the comment section below.
More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!