360 Secure SkillHub
360 安全技能中心

Whoami Tool

该 Skill 提供 whoami-tool 命令,用于打印当前有效用户名;可通过 --full、--uid、--groups、--json、--check 等选项获取 UID/GID、主组、全部组、JSON 结构化信息,或进行用户名匹配检查,适合脚本记录用户上下文与访问控制验证。

dinghaibin
dinghaibin
热度 16.02
最近更新 2026-05-14 00:31:09
分类:安全依赖:代码执行 / 读写文件应用场景:自动化脚本 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add whoami-tool
Metadata
name
whoami-tool
description
Print the current effective username. Simple identity query for scripts, session tracking, and access control verification.

Whoami Tool — Current User Identity

Display the current effective username (and optionally uid/gid/group membership). Essential for scripts that need to verify permissions, log user context, or conditionally execute based on identity.

Quick Start

# Show current username
whoami-tool

# Show full identity
whoami-tool --full

Usage

whoami-tool [OPTIONS]

Options:
  --full         Show username, UID, GID, and primary group
  --uid          Show numeric user ID only
  --groups       Show all group memberships
  --json         Output as structured JSON
  --check USER   Exit 0 if current user matches, 1 if not

Examples

# Basic username
whoami-tool

# Full user identity
whoami-tool --full

# Check if running as root (for privilege checks)
whoami-tool --check root && echo "Running as root"

# Show all groups
whoami-tool --groups

# JSON output for logging
whoami-tool --json

# UID for numeric comparisons
whoami-tool --uid

Features

  • Quick identity — one command to know who you are
  • Full mode — UID, GID, primary group
  • Group membership — all groups the user belongs to
  • Identity check — conditional execution based on username
  • JSON output — structured for logging and automation
  • Exit codes — 0 = success, useful for script conditionals