List Users with sudo Rights on Linux
Lists members of the sudo and wheel groups and extra rules under /etc/sudoers.d.
- Windows18
- macOS5
- Linux5
- Network3
- Disk and storage4
- Inventory4
- Security9
- Updates4
- Maintenance4
Script
#!/bin/bash
for group in sudo wheel admin; do
members=$(getent group "$group" | cut -d: -f4)
[ -n "$members" ] && echo "$group: $members"
done
if [ -d /etc/sudoers.d ]; then
echo
echo "Rules in /etc/sudoers.d:"
grep -hv '^\s*#' /etc/sudoers.d/* 2>/dev/null | grep -v '^\s*$'
fiRun it on every device with Moftgate
- 01
Add the script
In the Moftgate console, open Scripts > New script and paste the code.
- 02
Select the OS
Select Linux as the target operating system.
- 03
Test it
Run it on one test device first and read the output.
- 04
Roll out
Send it to all targets by group, profile or tag. Each device result is recorded separately.
These may help too
List Failed SSH Logins on Linux
Counts failed SSH password attempts in the last 24 hours by source IP. Use it to spot brute-force attacks.
Windows · PowerShellCheck BitLocker Encryption Status
Shows BitLocker protection status, encryption percent and method for each volume. Exits with an error if the system drive is not encrypted.
Windows · PowerShellCheck Microsoft Defender Status
Shows whether real-time protection is on, the signature version and the signature age. Warns when signatures are older than 3 days.
Manage scripts from one console
Target selection, a confirmation step, per-device output and an audit log. The first 200 endpoints are free for a year.