easyMultiple ChoiceObjective-mapped
Google ACE A GCP project has three service accounts Practice Question
A GCP project has three service accounts. A developer wants to list all service accounts in the project using the gcloud CLI. Which command is correct?
⚠ Common exam trap
Google Cloud often tests the exact hierarchical structure of gcloud commands, and the trap here is that candidates may confuse the `gcloud iam` subcommand syntax (where the resource type comes before the verb) with other command groups (like `gcloud compute` where the verb often comes first), leading them to choose Option B or D.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
gcloud iam service-accounts list
The `gcloud iam service-accounts list` command is the standard gcloud CLI command to list all service accounts in a GCP project. It uses the IAM API to retrieve the service accounts associated with the current project (or a specified project via the `--project` flag). This command is part of the `gcloud iam` group, which manages IAM resources, and the `service-accounts` sub-group specifically handles service account operations.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
gcloud service-accounts list
Why it's wrong here
The `gcloud service-accounts list` command is invalid because the gcloud CLI has no top-level `service-accounts` command group. Service account commands are nested under the IAM service, so the correct invocation is `gcloud iam service-accounts list`. Running this will return an error such as `ERROR: (gcloud) Command name 'service-accounts' not found` and require you to use the proper hierarchical path.
- ✗
gcloud iam list service-accounts
Why it's wrong here
The command `gcloud iam list service-accounts` fails because the subcommand ordering is incorrect. The gcloud IAM resource hierarchy places the resource type (`service-accounts`) immediately after `iam`, with the action (`list`) as the final element: `gcloud iam service-accounts list`. The `list` verb is not a direct child of `iam`, so this ordering produces a syntax error.
- ✓
gcloud iam service-accounts list
Why this is correct
The command `gcloud iam service-accounts list` is the correct and canonical way to list all service accounts in the active project. It returns a table of service account emails, display names, and unique IDs by querying the IAM Service Accounts API. You can specify a non-default project with `--project` or `--filter` to narrow results, making it a reliable and standard administrative operation.
- ✗
gcloud projects list-service-accounts
Why it's wrong here
The command `gcloud projects list-service-accounts` is invalid because `gcloud projects` manages project-level metadata and IAM policies, not service accounts as a subcommand. Service accounts are IAM resources, and their lifecycle (including listing) is under `gcloud iam service-accounts`. There is no `list-service-accounts` action under the `projects` command group, so this will result in an unknown command error.
Go deeper
Related to this question
Learn chapter
GCP IAM and Service Accounts
Key term
Service account
A service account is a special type of account used by an application or a virtual machine, rather than a human user, to authenticate and interact with cloud services and APIs securely.
Key term
gcloud CLI
The gcloud CLI is a command-line tool that lets you manage Google Cloud resources by typing commands instead of clicking through a web interface.
About these practice questions
One of 769 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.