Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
There is a Linux command who. Who am i is not a valid form of that command, as am i are not valid arguments for who. Consequently, who am i is not a valid command. See man who for more about the who command.
(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
[username] pts/1
My Slackware system just ignored the am i, knowing they weren't valid, and responded as if the command had been a simple who.)
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.
Last edited by frankbell; 06-02-2017 at 12:07 AM.
Reason: Clarity
I see that who without additional arguments returns all logged in users; who -m seems to return the user that invoked who.
From the man page:
Code:
-m only hostname and user associated with stdin
With that switch, it performs the same function as whoami, but returns a bit more information (pts, etc.)
Not exactly. 'whoami' prints the username for the effective userid, 'who am i' prints the user associated with stdin. For example, if you use 'su' or 'sudo' to switch to a different user, 'whoami' and 'who am i' will be different. They distinguish between who you logged in as (who am i) vs. the user you are right now (whoami).
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
root
Pegasus ~ # who am i
thomas pts/1 2017-08-19 11:15 (:0.0)
Pegasus ~ # who -m
thomas pts/1 2017-08-19 11:15 (:0.0)
Pegasus ~ # who
thomas tty8 2017-08-19 10:18 (:0)
thomas pts/1 2017-08-19 11:15 (:0.0)
thomas pts/5 2017-08-19 16:16 (:0.0)
Pegasus ~ # who am i | awk '{print $1}'
thomas
Pegasus ~ #
but
Example #2 from a gnome-terminal (same computer, same commands)
Code:
Pegasus ~ # whoami
root
Pegasus ~ # who am i
Pegasus ~ # who -m
Pegasus ~ # who
thomas tty8 2017-08-19 10:18 (:0)
thomas pts/1 2017-08-19 11:15 (:0.0)
thomas pts/5 2017-08-19 16:16 (:0.0)
Pegasus ~ # tty
/dev/pts/5
Pegasus ~ # ls -l `tty`
crw--w---- 1 thomas tty 136, 5 août 20 23:36 /dev/pts/5
Pegasus ~ # ls -l `tty` | awk '{print $3}'
thomas
Pegasus ~ #
This seems to be a consequence of gnome-terminal not adding utmp entries…
Last edited by Thomas Baeckeroot; 08-20-2017 at 05:45 PM.
Reason: nicer, clearer
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.