Cybersecurity Triage
Read-onlyList Users with Login Shells
You need to list accounts with shell-like login programs.
Command
awk -F: '$7 ~ /sh$/ {print $1, $7}' etc/passwd
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not disable accounts from this output alone; confirm ownership and operational use first.
Expected output
Usernames and login shells for accounts ending in sh.
System impact
Read-only. Nothing changes. The command reads account records and prints shell users.
Recovery / rollback: no state is changed.
When to use it
Use during account inventory, server handoff, or first-response checks.
When not to use it
Do not disable accounts from this output alone; confirm ownership and operational use first.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ cat etc/passwd
root:x:0:0:root:/root:/bin/bash
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
alex:x:1000:1000:Alex:/srv/example/users/alex:/bin/bash
deploy:x:1001:1001:Deploy:/srv/example/users/deploy:/bin/bash
backup:x:1002:1002:Backup:/srv/backup:/usr/sbin/nologin
$ awk -F: '$7 ~ /sh$/ {print $1, $7}' etc/passwd
root /bin/bash
alex /bin/bash
deploy /bin/bash
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
cat etc/passwdawk -F: '$7 ~ /sh$/ {print $1, $7}' etc/passwd
next steps
Related commands
Find SSH Keys for nologin Users
A nologin shell does not automatically mean SSH keys are irrelevant.
comm -12 <(awk -F: '$7 !~ /(bash|sh|zsh)$/ {print $1}' fixtures/user-access-audit/etc/passwd | sort) <(find fixtures/user-access-audit/home -path '*/.ssh/authorized_keys' -printf '%h\n' | awk -F/ '{print $(NF-1)}' | sort)
List Accounts with Login Shells
Login shells are the first account inventory to review.
awk -F: '$7 ~ /(bash|sh|zsh)$/ {printf "%s %s\n", $1, $7}' fixtures/user-access-audit/etc/passwd
Find Password-Enabled Accounts
A shell account with an unlocked password hash deserves extra attention.
awk -F: '$2 !~ /^(!|\*)/ {print $1}' fixtures/user-access-audit/etc/shadow
Find SSH Key Users with sudo
The highest-priority access review starts where SSH keys and sudo overlap.
comm -12 <(find fixtures/user-access-audit/home -path '*/.ssh/authorized_keys' -printf '%h\n' | awk -F/ '{print $(NF-1)}' | sort) <(awk -F: '$1=="sudo" {gsub(",","\n",$4); print $4}' fixtures/user-access-audit/etc/group | sort)
Extract SSH AllowUsers Accounts
AllowUsers turns SSH access into an explicit account list.
awk '/^AllowUsers/ {for (i = 2; i <= NF; i++) print $i}' etc/ssh/sshd_config
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.