Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Network Checks with ping, ss, curl | Monitoring and Diagnostics
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Linux Terminal Tools

bookNetwork Checks with ping, ss, curl

Network troubleshooting is a crucial skill for any Linux user, whether you are managing servers, developing applications, or simply ensuring your system is connected. Several command line tools are available to help you quickly diagnose and understand network connectivity and performance issues. Among the most essential are ping, ss, and curl. Each serves a unique purpose: ping checks basic reachability and latency, ss examines open sockets and connections on your system, and curl allows you to interact with web endpoints or APIs directly from the terminal. Understanding how and when to use these tools will help you efficiently pinpoint and resolve network problems.

ping -c 4 google.com

The ping command sends ICMP echo requests to a remote host and waits for replies, allowing you to check whether a host is reachable and measure the time taken for each packet. The -c option specifies the number of packets to send, which is useful for limiting the test. In the output, you can see each response, the round-trip time (time), and a summary at the end showing packet loss and average latency. If you see 100% packet loss or no replies, it usually means the host is unreachable or ICMP is blocked. Use ping for quick, basic connectivity tests and to measure network latency.

ss -tuln

The ss command is a powerful utility for inspecting your system's network sockets and connections. The -tuln options list TCP (-t), UDP (-u), listening (-l), and show numeric addresses and ports (-n). This helps you see which ports are open and which services are listening. You can further filter connections, such as viewing only established TCP connections with ss -t state established. Use ss to understand what network services are running, check for unexpected open ports, or troubleshoot local connectivity issues.

The curl tool allows you to make HTTP requests directly from the terminal. With the -I option, curl fetches only the HTTP headers, which is useful for quickly checking if a web server is up and responding. You can also use curl to retrieve the full content of a web page or interact with APIs by specifying additional options. This makes curl invaluable for diagnosing web service availability, checking API responses, or debugging client-server interactions.

curl -I https://example.com
When to use ping
expand arrow
  • Use ping when you want to verify if a remote host is reachable over the network;
  • Check for packet loss or high latency to diagnose connectivity or performance issues;
  • Limitations: does not test specific ports or services, and may be blocked by firewalls.
When to use ss
expand arrow
  • Use ss to inspect which ports and services are open on your local machine;
  • Identify active or listening network connections and troubleshoot service bindings;
  • Limitations: only shows local system sockets, not remote host status.
When to use curl
expand arrow
  • Use curl for checking the availability and response of web servers or APIs;
  • Test HTTP(S) endpoints, retrieve headers, or fetch content directly from the terminal;
  • Limitations: only works with application layer protocols like HTTP, not general network reachability.
question mark

Which tool should you use if you want to check whether a web server is responding with the correct HTTP headers?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

bookNetwork Checks with ping, ss, curl

Glissez pour afficher le menu

Network troubleshooting is a crucial skill for any Linux user, whether you are managing servers, developing applications, or simply ensuring your system is connected. Several command line tools are available to help you quickly diagnose and understand network connectivity and performance issues. Among the most essential are ping, ss, and curl. Each serves a unique purpose: ping checks basic reachability and latency, ss examines open sockets and connections on your system, and curl allows you to interact with web endpoints or APIs directly from the terminal. Understanding how and when to use these tools will help you efficiently pinpoint and resolve network problems.

ping -c 4 google.com

The ping command sends ICMP echo requests to a remote host and waits for replies, allowing you to check whether a host is reachable and measure the time taken for each packet. The -c option specifies the number of packets to send, which is useful for limiting the test. In the output, you can see each response, the round-trip time (time), and a summary at the end showing packet loss and average latency. If you see 100% packet loss or no replies, it usually means the host is unreachable or ICMP is blocked. Use ping for quick, basic connectivity tests and to measure network latency.

ss -tuln

The ss command is a powerful utility for inspecting your system's network sockets and connections. The -tuln options list TCP (-t), UDP (-u), listening (-l), and show numeric addresses and ports (-n). This helps you see which ports are open and which services are listening. You can further filter connections, such as viewing only established TCP connections with ss -t state established. Use ss to understand what network services are running, check for unexpected open ports, or troubleshoot local connectivity issues.

The curl tool allows you to make HTTP requests directly from the terminal. With the -I option, curl fetches only the HTTP headers, which is useful for quickly checking if a web server is up and responding. You can also use curl to retrieve the full content of a web page or interact with APIs by specifying additional options. This makes curl invaluable for diagnosing web service availability, checking API responses, or debugging client-server interactions.

curl -I https://example.com
When to use ping
expand arrow
  • Use ping when you want to verify if a remote host is reachable over the network;
  • Check for packet loss or high latency to diagnose connectivity or performance issues;
  • Limitations: does not test specific ports or services, and may be blocked by firewalls.
When to use ss
expand arrow
  • Use ss to inspect which ports and services are open on your local machine;
  • Identify active or listening network connections and troubleshoot service bindings;
  • Limitations: only shows local system sockets, not remote host status.
When to use curl
expand arrow
  • Use curl for checking the availability and response of web servers or APIs;
  • Test HTTP(S) endpoints, retrieve headers, or fetch content directly from the terminal;
  • Limitations: only works with application layer protocols like HTTP, not general network reachability.
question mark

Which tool should you use if you want to check whether a web server is responding with the correct HTTP headers?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 4
some-alt