Showing posts with label curl. Show all posts
Showing posts with label curl. Show all posts

Wednesday, March 24, 2021

How to find the file size of a remote HTTP object?


There are times when you need to know the file size of an HTTP object without actually downloading the file. This little trick comes in very handy when web servers respond with the Content-Length of an object in the HEAD request itself.


Using curl command:


Example:


curl -sI https://releases.ubuntu.com/20.04.2.0/ubuntu-20.04.2.0-desktop-amd64.iso | grep Content-Length


Content-Length: 2877227008


Let’s try and make this human-friendly:


curl -sI https://releases.ubuntu.com/20.04.2.0/ubuntu-20.04.2.0-desktop-amd64.iso | grep Content-Length | sed 's/[^0-9]//g' | numfmt --to=si

2.9G



Where The Numfmt command will convert the numbers to/from human-readable format.


Tuesday, April 28, 2020

how to find my public ip address in linux ?

Using dig


dig (domain information groper) is a simple command line utility for probing DNS name servers. To find your public IP addresses, use the opendns.com resolver as in the command below:


Syntax:


dig +short myip.opendns.com @resolver1.opendns.com


Example:


dig +short myip.opendns.com @resolver1.opendns.com


111.125.200.200


Using host


host command is an easy-to-use command line utility for carrying out DNS lookups. The command below will help to display your system public IP address.


Syntax:
host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'


Example:


host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
111.125.200.200


Using wget


curl is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following
commands display your public IP address.


Syntax:


wget -qO- http://ipecho.net/plain | xargs echo


Or


wget -qO - icanhazip.com


Example:


 wget -qO- http://ipecho.net/plain | xargs echo
111.125.200.200


 wget -qO- http://ipecho.net/plain | xargs echo
111.125.200.200


Using curl


curl is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following
commands display your public IP address.


Syntax:


curl ifconfig.me


Example:
curl ifconfig.me
111.125.200.200


The following commands will get you the IP address list to find public IP addresses for your machine:

  • curl ifconfig.me
  • curl icanhazip.com
  • curl ipinfo.io/ip
  • curl api.ipify.org
  • curl checkip.dyndns.org
  • curl ident.me
  • curl bot.whatismyipaddress.com
  • curl ipecho.net/plain