Only scan systems you own or have written permission to test.
nmap -sn 192.168.1.0/24 # host discovery (ping scan), no port scan
sudo nmap -sS -p- 192.168.1.20 # SYN scan of all TCP ports
nmap -sV -p 22,80,443 192.168.1.20 # service and version detection
sudo nmap -O 192.168.1.20 # OS guess (needs root)
nmap -p 443 --script ssl-cert example.org # read a certificate
Use it defensively: scan your own servers from the outside to see what the internet sees, and compare with what you expect to be open. Anything unexpected is a finding. Scanning can trigger intrusion detection and can disturb fragile devices (old printers, IoT); use gentler timing (-T2) and avoid scanning other people's networks.