shell获取当前用户名或者ID

[user@localhost fix_bug_srpm]$ echo "$USER"
user
[user@localhost fix_bug_srpm]$ echo `id -u`
503
[user@localhost fix_bug_srpm]$ echo `whoami`
user
[user@localhost fix_bug_srpm]$ echo `who am i`
user pts/1 2009-10-26 10:49 (:0.0)
[user@localhost fix_bug_srpm]$ who
user     tty1         2009-10-26 09:29 (:0)
user     pts/0        2009-10-26 10:43 (:0.0)
user     pts/1        2009-10-26 10:49 (:0.0)
[user@localhost fix_bug_srpm]$ echo "$UID"
503

你可能感兴趣的:(shell bash 用户名)