whoami
If I ssh to a linux server, and use whoami
, it will print effective userid:
$ whoami
bo
And if I su to root, then do the whoami
again, it will print root
:
$ whoami
root
who
who
will show who is logged on.
$ who
bo pts/0 2020-01-09 11:33
Even if I already su to root:
$ su
$ whoami
root
$ who
bo pts/0 2020-01-09 11:33
who am i
Huh? I heard who
, but I don't know you can run who am i
.
$ who am i
bo pts/0 2020-01-09 11:33
And what's the difference with who
? The answer is, who
will show all users who has a login-tty, and who am i
will only show the current login-tty user. Say if I ssh'ed to server in another terminal window, then run who
and who am i
:
$ who
bo pts/0 2020-01-09 11:33
bo pts/1 2020-01-09 11:45
$ who am i
bo pts/0 2020-01-09 11:33
Now you can see the difference. Ok, if this weird who am i
works, how about who are you
? Let's try:
$ who are you
bo pts/0 2020-01-09 11:33
$ who is this
bo pts/0 2020-01-09 11:33
$ who logged on
bo pts/0 2020-01-09 11:33
They all print the same thing as who am i
! Actually as long as there are 2 parameters followed by who
, it will print the current login-tty user, no matter what the parameters are.
But you can't run it with 3 parameters, it will print errors:
$ who is this tty
who: extra operand ‘tty’
Try 'who --help' for more information.
w
w will Show who is logged on and what they are doing, so it is like who
, plus the "what they are doing" info:
$ w
12:12:01 up 78 days, 15:52, 2 users, load average: 0.25, 0.34, 0.29
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
bo pts/0 67.xx.xx.xx 11:33 0.00s 0.13s 0.00s sshd: bo[priv]
bo pts/1 67.xx.xx.xx 11:45 26:49 0.04s 0.04s -bash
Then can we use w am i
? let's try it:
$ w am i
12:15:25 up 78 days, 15:55, 2 users, load average: 0.08, 0.22, 0.25
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
You can see it only prints the header info, but no users in the USER section. This is because with extra parameter, w
will only take the first parameter as a user id and print user with that id. So for w am i
, it will try to find a user with user id am
, if this user exists and has a login-tty open, print it out, otherwise show nothing.
$ w bo
12:17:01 up 78 days, 15:57, 2 users, load average: 0.25, 0.34, 0.29
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
bo pts/0 67.xx.xx.xx 11:33 0.00s 0.13s 0.00s sshd: bo[priv]
bo pts/1 67.xx.xx.xx 11:45 26:49 0.04s 0.04s -bash
Top comments (12)
The cli is a more modern version of Alexa, you don't even have to talk to it, you just type it. And some of us are more comfortable writing than talking :)
haha, among the 3 big philosophy questions: "Who am I? Why am I here? Where do I find meaning?" Apparently cli is modern and smart enough to answer one of them - who am i -, it won't take long to answer the rest two. (I hope the answer is not 42) 😊
It's kinda interesting tho, I'm not sure Adams was aware of the phenomena whein made the 42; with AI we put the question and get the answer, no clue about the process or rationale behind it; we'll know the answers not knowing why, historically the usual process was scientists discovered something and engineers behind looked for uses; that will probably invert in the future, engineers with AI will get answers and scientists behind will try to understand why did it work, like archeology. God indeed will work in misterious ways. And could it be a de-facto god if we made it? what would make us?, and to be this kind of all (or almost) know all "god" the AI needs to have what we see as concience? have to even pass the Turing test? could it be a dumb god? that knows everything but itself?...
... ok, that was way to much coffee for me, I'm gonna take a cold shower now.
I think it is already happening, one of my professor who has CS and Math background is working on explaining the deep learning network with Optimal Mass Transportation Theory, Convex Geometry and Monge-Ampere Equation.
Besides that, interesting thoughts 🤔
I never was so offended by something that I agree with. Some of us just can't talk to human beeings.
hahaha, I fear the day AI gets "human" enough to make those interactions akward too :D
Gonna throw
finger
into the mix?oh, I never used
finger
before, thank you Ben for sharing this.Seems it doesn't come with the default shell commands set, need to do
apt install finger
, and the output seems similar tow
? Can you share more of the benefits using it compare tow
if you don't mind?It used to be used all the time, but it's fallen out of favour. It's insecure, it was a plain-text client-server system so you could say
finger ben@scramble.moopet.net
or even justfinger @scramble
and it would interrogate the finger daemon on that host. If you set a file in your home directory called.plan
it would display as part of the finger output:There's a good overview of it here: computerhope.com/unix/ufinger.htm
Benefits include being able to query remote hosts, and being able to control what people can see about you by editing files in your home.
There's also the
last
command, which will give a listing of who was logged in:I see, "being able to query remote hosts" this would be useful in some cases, gonna read more on it, thank you Ben :D
This is really cool!
thank you Jason :D