ip addr (or ip a) shows the network interfaces and their addresses. lo is the loopback, 127.0.0.1, which always means this machine; names like eth0, ens3 or wlan0 are real network cards. ip route shows the default gateway, the router traffic leaves through.
$ ip -brief addr
lo UNKNOWN 127.0.0.1/8 ::1/128
ens3 UP 203.0.113.20/24
To test a connection, work outward. ping 1.1.1.1 checks you can reach the internet at all (Ctrl+C stops it). ping example.com adds a name lookup, so if the first works and the second doesn't, the problem is DNS, the system that turns names into addresses. dig example.com or host example.com asks DNS directly, and /etc/hosts lets you set names by hand.
curl fetches a web address and prints what comes back: curl -I https://example.com shows just the response headers, a quick way to check a site answers. wget downloads files.
A service listens on a port: 22 for SSH, 80 for web, 443 for secure web, 5432 for PostgreSQL. sudo ss -tlnp lists the listening TCP ports and which program has each one. A service listening on 127.0.0.1 is only reachable from the machine itself; 0.0.0.0 means every interface.
$ sudo ss -tlnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=812,fd=6))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=640,fd=3))
A firewall decides which ports the outside world can reach. Ubuntu's ufw keeps it simple: sudo ufw allow 22, sudo ufw allow 443, then sudo ufw enable. Allow SSH before you enable it on a remote server, or you'll lock yourself out.