Based on the Linux Master 1 exam syllabusReport an error
ss -tlnp = tcp listen numeric process. It is the standard combination for seeing "which process is listening on which port".ping uses ICMP Echo request/reply to check whether IP packets travel to and from the target host.ping google.com # keeps going until you stop it with Ctrl+C
ping -c 4 8.8.8.8 # send only 4 and exit
ping -i 0.5 8.8.8.8 # 0.5-second interval
ping -s 1000 8.8.8.8 # packet size of 1000 bytes
ping -W 2 8.8.8.8 # wait 2 seconds for a replyIf ping 8.8.8.8 (IP) works but ping google.com (domain) fails, the network is fine and DNS is the problem. Conversely, if even the IP fails, it is an IP/route/firewall problem. This one-line comparison instantly separates a DNS problem from a connectivity problem.
⚠️ Trap: a failed ping does not mean the host is dead. Many servers and firewalls block ICMP for security. It is common for "ping to be blocked while ports 80/443 are open and the web works fine". Do not jump to the conclusion that a ping failure is an outage.
traceroute shows the routers (hops) along the way to the destination, in order.traceroute google.com
traceroute -n 8.8.8.8 # IPs only, no name resolution (faster)
tracepath google.com # similar to traceroute, can also be run by regular usersKey distinction: ping only tells you "does it reach the final destination", but traceroute shows "at which intermediate point it gets blocked". If the first few hops are fine and then * * * appears from a particular hop, the problem is beyond that point. When a ping fails, use traceroute to narrow down where it breaks.
netstat is legacy (net-tools), and ss is the modern one (iproute2) and is faster.| Option | netstat | ss | Meaning |
|---|---|---|---|
| Listening ports | netstat -l | ss -l | LISTEN state |
| TCP | netstat -t | ss -t | TCP only |
| UDP | netstat -u | ss -u | UDP only |
| Numeric display | netstat -n | ss -n | Skip name resolution (fast) |
| Process | netstat -p | ss -p | Process/PID holding the port |
| All | netstat -a | ss -a | All sockets |
# The most commonly used combination: listening TCP ports and the processes holding them
ss -tlnp # TCP, LISTEN, numeric, process
netstat -tlnp # same (legacy)
# Listening UDP ports
ss -ulnp
# Routing table (in the case of netstat)
netstat -rn # = ip routeEach option letter has a meaning. ss -tlnp = tcp listen numeric process = "which process is listening on which TCP port". When a service won't come up, ss -tlnp | grep :80 instantly shows who is listening on port 80 (or that nobody is).
Key distinction: the TCP connection states are as follows. LISTEN (waiting), ESTABLISHED (connected), TIME_WAIT (lingering after close), SYN_SENT (attempting to connect). If too much TIME_WAIT piles up, it is a sign of port exhaustion, and if SYN_SENT is stuck, the other side is not responding.
# nslookup (interactive/simple)
nslookup google.com
nslookup google.com 8.8.8.8 # query a specific DNS server
# dig (detailed — the practical standard)
dig google.com # A record
dig google.com MX # mail server record
dig google.com +short # just the IP, concise
dig -x 8.8.8.8 # reverse lookup (IP → domain)
# host (concise)
host google.com
host -t MX google.com # MX records only| Record | Meaning |
|---|---|
| A | Domain → IPv4 address |
| AAAA | Domain → IPv6 address |
| MX | Mail server |
| CNAME | Alias (points to another domain) |
| NS | Name servers of that domain |
| PTR | IP → domain (reverse) |
dig has rich output (query time, responding server, TTL, authority), making it the standard for practical debugging. You can extract just the answer with +short. nslookup is simpler but is sometimes treated as deprecated. "Querying a specific DNS server" takes the form dig @server domain or nslookup domain server.
⚠️ Trap:
digdoes not look at/etc/hostsand queries the DNS server directly. So an entry you registered in hosts may resolve withpingbut not show up withdig. "ping works but dig returns NXDOMAIN" = it is a hosts mapping, not a DNS entry.
arp -n # ARP table (numeric display)
arp -a # a different format
ip neigh show # modern (= arp -n)
# Delete an entry
arp -d 192.168.1.50Key distinction: ARP only works within the same network (L2 domain). Hosts on other networks do not appear in the ARP table; instead, the gateway's MAC plays that role. In a "same subnet but can't communicate" problem, if the other side's MAC shows (incomplete) in the ARP table, it means L2 reachability itself has failed.
tcpdump -i eth0 # all packets on eth0
tcpdump -i eth0 -n # no name resolution (fast)
tcpdump -i eth0 port 80 # port 80 only
tcpdump -i eth0 host 192.168.1.50 # a specific host only
tcpdump -i eth0 tcp # TCP only
tcpdump -i eth0 -c 10 # capture 10 and exit
tcpdump -i eth0 -w capture.pcap # save to a file (for Wireshark analysis)tcpdump combines filters (port, host, tcp/udp, src/dst) to show only the traffic you want. Example: tcpdump -i eth0 -n 'tcp port 443 and host 1.1.1.1'. It is the last-resort tool for seeing with your own eyes "whether the firewall really blocks the packets" and "whether replies come back when the SYN goes out". It requires root privileges.
# 1. Which ports are in LISTEN locally?
ss -tlnp
# 2. Is a specific port on a remote host open? (telnet/nc)
nc -zv 192.168.1.50 80 # test a connection to port 80
telnet 192.168.1.50 80 # old-fashioned but still widely used
# 3. Well-known port numbers
# 22=SSH, 23=Telnet, 25=SMTP, 53=DNS, 80=HTTP, 443=HTTPS
# 110=POP3, 143=IMAP, 21=FTP, 3306=MySQL, 8080=alternate HTTPKey distinction: 0-1023 are well-known ports that only root can bind. 1024-49151 are registered ports, and anything above that are dynamic ports. "A service running with regular-user privileges can't open port 80" because 80 is below 1024 and needs root privileges.
# Flow: from near to far, from low layers to high layers
ping -c 2 127.0.0.1 # 1. The machine itself (is the TCP/IP stack OK?)
ping -c 2 192.168.1.1 # 2. The gateway (are L2/L3 OK?)
ping -c 2 8.8.8.8 # 3. An external IP (are routing/firewall OK?)
ping -c 2 google.com # 4. A domain (is DNS OK?)
ss -tlnp # 5. Check local service portsTomorrow (Day 4) we organize, by layer, the devices and protocols these packets actually pass through.
ss / netstat: the modern and legacy tools for viewing socket, port, and connection state.dig: the standard tool that queries a DNS server directly. The trap is that it does not look at /etc/hosts.(incomplete): an indication in the ARP table that no MAC reply was received from the other side. L2 reachability itself has failed.port, host, tcp/udp, and src/dst to capture only the desired traffic.Click a choice to reveal the answer and explanation.
Question 1
ping 8.8.8.8 succeeds but ping google.com fails. What is the most likely cause?
Question 2
Which command correctly shows the listening TCP ports on the current system together with the processes holding them?
Question 3
ping cannot reach the destination. Which command do you use to check at which router (hop) along the path the traffic breaks?
Question 4
Among TCP connection states, which one is where "a server waits for a client's connection request"?
Question 5
Which statement about dig is correct?
Question 6
Which statement about the "well-known ports" in the range 0-1023 is correct?
Question 7
You cannot communicate with host 192.168.1.50 on the same subnet, so you check arp -n and the MAC for that IP shows (incomplete). What is the most accurate meaning?