nerdexam
Linux_Foundation

KCNA · Question #1

Which is the correct kubectl command to display logs in real time?

The correct answer is D. kubectl logs -f test-container-1. The kubectl logs command with the -f flag is used to stream logs from a container in real-time, similar to tail -f.

Submitted by fatema_kw· May 4, 2026Cloud Native Observability

Question

Which is the correct kubectl command to display logs in real time?

Options

  • Akubectl logs -p test-container-1
  • Bkubectl logs -c test-container-1
  • Ckubectl logs -l test-container-1
  • Dkubectl logs -f test-container-1

How the community answered

(36 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    6% (2)
  • D
    89% (32)

Why each option

The `kubectl logs` command with the `-f` flag is used to stream logs from a container in real-time, similar to `tail -f`.

Akubectl logs -p test-container-1

The `-p` or `--previous` flag displays logs from a previous instantiation of a container, not real-time logs.

Bkubectl logs -c test-container-1

The `-c` or `--container` flag specifies a container name when a Pod has multiple containers, but it doesn't enable real-time following.

Ckubectl logs -l test-container-1

The `-l` or `--selector` flag filters Pods based on a label selector, it does not relate to real-time log following.

Dkubectl logs -f test-container-1Correct

The `-f` or `--follow` flag for `kubectl logs` specifically enables following the log output in real-time, continuously streaming new log entries as they are generated by the container. This is essential for monitoring live application behavior and debugging issues as they occur.

Concept tested: kubectl logs command options

Source: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#logs

Topics

#kubectl#logs#real-time#observability

Community Discussion

No community discussion yet for this question.

Full KCNA Practice