Whoami

whoami截图

whoami操作系统中用于查看当前有效用户名的命令,自Windows Server 2003以来每个Windows 操作系统和大多数类Unix操作系统上都可以找到。它是英文“Who am I ?”(我是谁?)的拼接结果。当被调用时,打印当前用户的有效用户名。它与Unix命令id -un具有相同的效果。

在类Unix操作系统上,命令的输出与$USER稍有不同,因为whoami输出用户正在使用的用户名,而$USER输出用于登录的用户名。例如,假使用户以用户名John登录并使用命令su(su默认不调用login shell)获得了root权限,此时若使用whoami命令会输出root,而echo $USER对应的输出则是John。

该程序最早创建于 BSD 2.9 中,作为命令“who am i”我是谁的一种便利形式,即伯克利Unix(Berkeley Unix)打印登录用户身份的方式[1]。GNU版本由Richard Mlynarik编写,是GNU核心工具组(coreutils)的一部分。

该命令也可作为Windows 2000 Resource Kit[2]和Windows XP SP2支持工具的一部分[3]

除此以外,文件服务器上Netware的公共文件夹内也包含了该程序。它还输出当前工作站所连接的服务器的用户名。

使用示例

  • Unix/*nix:
# whoami
root
  • Windows 命令提示符:
C:\Users\admin>whoami
workgroup\admin

另请参见

参考内容

  1. ^ 2.9.1BSD Manual Page. [2018-04-28]. (原始内容存档于2018-04-29). 
  2. ^ Windows 2000 Resource Kit Tool: Whoami.exe. [2018-04-28]. (原始内容存档于2008-03-13). 
  3. ^ Windows XP Service Pack 2 Support Tools. [2018-04-28]. (原始内容存档于2010-09-06). 

外部链接

文件系統
程序
  • at
  • bg
  • chroot
  • cron
  • fg
  • kill
  • killall英语killall
  • nice
  • pgrep
  • pkill英语pkill
  • ps
  • pstree英语pstree
  • time
  • top
用户环境
  • clear
  • env
  • exit
  • history英语history (Unix)
  • id
  • logname
  • mesg英语mesg
  • passwd
  • su
  • sudo
  • uptime
  • talk英语talk (software)
  • tput英语tput
  • uname
  • w
  • wall英语wall (Unix)
  • who
  • whoami
  • write英语write (Unix)
文本编辑
  • awk
  • banner英语banner (Unix)
  • basename
  • comm英语comm
  • csplit英语csplit
  • cut
  • diff
  • dirname
  • ed
  • ex
  • fmt英语fmt
  • fold英语fold (Unix)
  • head英语head (Unix)
  • iconv
  • join英语join (Unix)
  • less
  • more
  • nl英语nl (Unix)
  • paste英语paste (Unix)
  • sed
  • sort英语sort (Unix)
  • spell英语spell (Unix)
  • strings英语strings (Unix)
  • tail
  • tr
  • uniq英语uniq
  • vi
  • wc
  • xargs
壳层内建
网络
查找
文档
  • apropos英语apropos (Unix)
  • help英语help (command)
  • man
软件开发
杂项
  • bc
  • cal
  • dc
  • expr
  • lp英语lp (Unix)
  • lpr
  • sleep
  • true和false
  • yes
文件管理导航
文件管理操作
  • attrib英语ATTRIB
  • cacls
  • cipher
  • compact
  • copy
  • del英语del (command) (erase)
  • deltree英语deltree
  • expand
  • icacls
  • makecab
  • md (mkdir)
  • move英语move (command)
  • rd (rmdir)
  • recover英语recover (command)
  • ren英语ren (command) (rename)
  • replace英语replace (command)
  • Rmdir
  • robocopy英语robocopy
  • xcopy英语XCOPY
磁盘管理
  • chkdsk
  • convert英语convert (command)
  • defrag
  • diskcomp英语diskcomp
  • diskcopy英语diskcopy
  • diskpart英语diskpart
  • fdisk英语fdisk
  • format英语Format (command)
  • label英语label (command)
  • subst英语SUBST
  • scandisk
  • sys英语SYS (command)
  • vol英语vol (command)
  • vssadmin
进程
  • exit
  • kill
  • powercfg英语powercfg
  • runas
  • sc
  • shutdown
  • start英语start (command)
  • taskkill
  • tasklist英语tasklist
注册表
用户环境
  • date
  • mode
  • path
  • set
  • setx
  • time英语TIME (command)
  • title
  • ver英语ver (command)
  • Whoami
文件内容
  • comp英语comp (command)
  • edit英语MS-DOS Editor
  • edlin英语edlin
  • fc英语Microsoft File Compare
  • find英语find (command)
  • findstr
  • print英语PRINT (command)
  • type英语TYPE (DOS command)
脚本
  • choice英语choice (command)
  • clip
  • cscript
  • doskey英语DOSKEY
  • echo
  • for
  • Goto
  • if
  • more
  • pause
  • prompt英语Command-line_interface#Command_prompt
  • rem
网络
维护
启动管理
软件开发
杂项
  • cls
  • help英语help (command)