"who am i " command
i tried running "who am i" command but there is no output,but my professor has "howard pts/2 2017-05-29 10:43 (:0)"
2.when i run whoami command its shows as tty not pts/ Thank you |
One command is $(whoami), then other is $(who) with parameters "am i".
$ whoami $ who am i |
BUT "WHOAMI" is giving me the username, but no output for "who am i"
|
Quote:
(The who command is completely different from the whoami command.) To put it another way, who am i asks as question that Linux cannot interpret, so, in your case at least, no answer is provided. It understands the who, but it doesn't understand the am i. It's sort of like asking, "What's your favorite make of automobile: Dell, Lenovo, or Zareason?" (I'm mildly surprised you didn't get something like I got: Code:
# who am i Indeed, we were talking about this at my LUG dinner tonight. Learning the command line is like learning a new language. It has nouns, verbs, and modifiers (nouns=files and folders, verbs=commands, modifiers=arguments to commands) and especially it has a very strict syntax. A human being can usually understand what you mean if you misspell a word or use the wrong tense of a verb; a computer cannot. The darn things xpect you to speek to them correctly, just as crossword puszles expect you to splet words rite. |
The man page for whoami basically says that it is equivalent to $(id -un)
$ id -un $ whoami versus something like $ who -a or $ id |
Quote:
|
man who on my ubuntu tells:
Code:
SYNOPSIS Code:
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual. |
Thanks. A nice tidbit!
Quote:
From the man page: Code:
-m only hostname and user associated with stdin |
Quote:
|
ls -l `tty`
WORKAROUND:
Code:
ls -l `tty` | awk '{print $3}' Code:
who am i | awk '{print $1}' Explanation: On many systems "who am i" is equivalent to "who -m". (I believe this works for most Linux but not all Unix? To be confirmed…) The problem here is that with some terminals, "who -m" returns nothing! Example #1 run from a xfce4-terminal on Mint 18+, after "sudo su" Code:
Pegasus ~ # whoami Example #2 from a gnome-terminal (same computer, same commands) Code:
Pegasus ~ # whoami |
All times are GMT -5. The time now is 10:58 PM. |