3. What will be the output of the command gcloud compute disks list --filter="zone:(us-central1-a)" if there are two disks named disk1 and disk2 in zone us-central1-a and one disk named disk3 in zone us-east1-b?
medium
A. Lists disk1, disk2, and disk3
B. Shows an error due to filter syntax
C. Lists only disk3
D. Lists only disk1 and disk2
Solution
Step 1: Understand the filter usage
The filter limits results to disks in zone us-central1-a only.
Step 2: Apply filter to disk list
Disks disk1 and disk2 are in us-central1-a, so they appear; disk3 is in a different zone and is excluded.
Final Answer:
Lists only disk1 and disk2 -> Option D
Quick Check:
Filter by zone shows matching disks only [OK]
Hint: Filter narrows results to matching zone disks only [OK]
Common Mistakes:
Assuming filter includes all disks
Misreading filter syntax
Expecting syntax error incorrectly
4. You run gcloud compute instances delete my-vm but get an error saying the zone is missing. What is the best fix?
medium
A. Add --project=PROJECT_ID flag instead.
B. Add the flag --zone=ZONE_NAME with the correct zone.
C. Run the command without any flags again.
D. Use gcloud delete instances my-vm instead.
Solution
Step 1: Identify missing required parameter
The error indicates the zone is not specified, which is required to delete an instance.
Step 2: Correct the command by adding zone
Adding --zone=ZONE_NAME specifies the location of the instance to delete.
Final Answer:
Add the flag --zone=ZONE_NAME with the correct zone. -> Option B
Quick Check:
Zone flag required for instance delete [OK]
Hint: Always specify zone when deleting or managing instances [OK]
Common Mistakes:
Ignoring zone requirement
Using wrong command syntax
Assuming project flag fixes zone error
5. You want to create a new persistent disk named data-disk of size 100GB in zone europe-west1-b and attach it to an existing instance app-server. Which sequence of commands is correct?
Step 1: Create the disk first with correct size and zone
The disk must be created before attaching. 1) gcloud compute disks create data-disk --size=100GB --zone=europe-west1-b 2) gcloud compute instances attach-disk app-server --disk=data-disk --zone=europe-west1-b uses correct size format '100GB' and specifies zone.
Step 2: Attach the created disk to the instance with zone specified
Attaching requires the disk and instance zone flags; 1) gcloud compute disks create data-disk --size=100GB --zone=europe-west1-b 2) gcloud compute instances attach-disk app-server --disk=data-disk --zone=europe-west1-b includes these correctly.
Final Answer:
First create disk with size and zone, then attach with disk and zone flags. -> Option A
Quick Check:
Create disk before attach, specify size with GB [OK]
Hint: Create disk before attach; size needs units like GB [OK]