هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
طريقة الكتابة
whoami [OPTION]...الخيارات 2
الأكثر استخدامًا
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 11
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Who am I?
whoami studentYour current user.
2After sudo
sudo whoami rootProves that sudo works for you.
3After su
su - admin -c whoami adminThe command runs as admin.
4Compare with the login name
whoami = now, logname = who logged in.
5Stop a script that must run as root
Many install scripts start with this check.
[ "$EUID" -eq 0 ]works too.6Stop a script that must NOT run as root
Build tools and package managers for users should not run as root.
7Show the user in a prompt or log
echo "$(date) $(whoami)@$(hostname): backup started" >> /var/tmp/ops.logWho started the job, on which host.
8Check the user of a container
podman run --rm registry.access.redhat.com/ubi10/ubi whoami rootMany images run as root by default; a security scan would flag this.
9Check the user of a cron job
Put
whoami > /tmp/cron-user.txtin a test job to see which user cron uses.10Check the user after a privilege escalation test
id; whoamiIn a pentest report,
whoamioutput proves the reached privilege level.11Use it in an SSH check
ssh server2 whoami studentConfirms the remote login user (useful with ProxyJump and keys).
لا يوجد شيء يطابق هذا الفلتر.
نصائح للحفظ
- whoami = effective user (after su/sudo). logname = original login. id = user plus groups.