You are asked to audit a server for risky accounts. What does your script check?
IntermediateScenarioScenarios: deployments, user management and fleet operations
Answer
Situation read → Look for privilege, missing passwords, passwordless sudo and stray keys.
What I'd do →
awk -F: '$3 == 0 && $1 != "root" {print "UID 0 account:", $1}' /etc/passwd
awk -F: '$2 == "" {print "empty password:", $1}' /etc/shadow
grep -rhE '^[^#].*NOPASSWD' /etc/sudoers /etc/sudoers.d/ 2>/dev/null
awk -F: '$3 >= 1000 && $7 !~ /(nologin|false)$/ {print $1}' /etc/passwd | while read -r u; do
f="/home/$u/.ssh/authorized_keys"; [[ -s $f ]] && echo "$u: $(grep -c . "$f") key(s)"
done
lastlog -b 90 | awk 'NR > 1 && $0 !~ /Never logged in/ {print "inactive 90d+:", $1}'
Why → These are the usual paths to unauthorized root: extra UID 0 accounts, blank passwords and unrestricted sudo.
Interview tip → Mention running audits as code (CIS benchmarks via Lynis or OpenSCAP) rather than only ad-hoc scripts.
More on Scenarios: deployments, user management and fleet operations
Write the core of a deploy script with release directories, an atomic symlink switch and rollback.IntermediateDeploy to 10 servers behind an AWS ALB one at a time, removing each from the target group during its deploy. Outline the script.AdvancedAfter a deploy, the health check fails intermittently. Your script must roll back automatically, but only if the failure persists. How?IntermediateImplement a blue/green switch on a single nginx host with a script.AdvancedOnboard 30 engineers: create accounts and install their SSH keys from their GitHub usernames, idempotently.IntermediateAn engineer leaves the company. Write the offboarding steps for Linux servers.Intermediate