WEBTOOLIST.
STATIC WEB PLATFORM
NO ACCOUNTS / NOTHING TO INSTALL

$ webtoolist --script path-audit

PATH Audit

Check PATH for missing, duplicate, or world-writable directories.

category Linux Utilities shell Bash 4+ updated 2026-08-17
pathshellauditenvironment
Safety notes
  • Read-only: inspects PATH and permissions.
  • Fixing the findings is a manual decision; do not blindly chmod system directories.

Usage

  • Run with the PATH you want to audit.
  • Investigate any world-writable directory before a binary there is trusted.

Script

#!/usr/bin/env bash
set -euo pipefail

declare -A seen=()
index=0

IFS=: read -r -a parts <<< "$PATH"
for dir in "${parts[@]}"; do
  index=$((index + 1))
  if [[ -z "$dir" ]]; then
    echo "warn  empty PATH entry (current directory) at position $index"
    continue
  fi
  if [[ -n ${seen[$dir]:-} ]]; then
    echo "warn  duplicate: $dir (positions ${seen[$dir]} and $index)"
    continue
  fi
  seen[$dir]="$index"

  if [[ ! -d "$dir" ]]; then
    echo "warn  missing: $dir"
    continue
  fi
  if [[ -w "$dir" && "$(stat -c '%a' "$dir")" =~ [2367]$ ]]; then
    echo "warn  world-writable: $dir"
  fi
  echo "ok    $dir"
done

Example

./path-audit
PATH=/usr/local/bin:/usr/bin:/bin ./path-audit

Notes

  • Duplicate entries are not harmful, but they make command resolution harder to reason about.
  • A world-writable PATH directory is a privilege-escalation risk; remove it or tighten permissions.

Related scripts

File Permission Audit

Find world-writable files and directories, excluding known-safe locations.

Security

Fuzzy Find Helper

Search filenames interactively with fzf when available, falling back to find.

Shell Productivity

SSH Hardening Audit

Inspect sshd configuration for common risky settings without changing anything.

Security