ubuntu 18.04 get public ip address

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

Also in Shell: