Send four ICMP echo requests to 192.0.2.1 and check replies and packet loss.
Exit automatically after sending them.
Which command is appropriate?
The iputils ping -c COUNT option sends the requested number of echo requests and then exits.
Detailed explanation
ping -c 4 192.0.2.1Correct. It sends four requests and then exits.
Correct. It sends four requests and then exits.
ping -i 4 192.0.2.1Incorrect. -i sets the interval but does not limit the total count.
Incorrect. -i sets the interval but does not limit the total count.
ping -s 4 192.0.2.1Incorrect. -s sets the payload size.
Incorrect. -s sets the payload size.
ping -W 4 192.0.2.1Incorrect. -W adjusts the reply timeout.
Incorrect. -W adjusts the reply timeout.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'ping -c 4 -> send four echo requests and stop'Expected result
ping -c 4 -> send four echo requests and stopKey points
- -c sets the count
- Check packet loss
- Distinguish -i, -s, and -W
Notes
- Environment: iputils pingのoption対応表(外部通信なし)
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.