Skip to main content

For what reason would you need to find the identity of the current user? You are the current user!  However, if you are like me and run multiple user accounts for different domains, then having the ability to quickly check is important.

who

The output from who gives you the name of the current user (denoted below as {username}), the terminal they are logged in at, the date and time when they logged in and the IP address:

{username} pts/0       2020-09-03 11:04 (ip address)

whoami

Whereas, whoami returns the short by direct response:

{username}

The w command provides us with not only the user name, but a bunch of extra details. Multiple users will all be listed with the w command. At the time of performing command w, I had three shell windows open... so yes I had three users listed.  pts/0, pts/1 and pts/2 were in order of the log in.

The w command provides the boot time, uptime and average load for the previous five, ten and fifteen minutes, and the following information regarding the current user.

USER The user name
TTY The type of terminal they are logged in at. This will usually be a pts (a pseudo-teletype). :0 means the physical keyboard and screen connected to this computer
FROM The name of the remote host if this is a remote connection
LOGIN@ The time at which the user logged in
IDLE Idle time
JCPU Joint CPU time, this is the CPU time used by all processes that have been attached to this TTY
PCPU Process CPU time, this is the CPU time used by the current process. The current process is named in the WHAT column
WHAT The command line of this user’s current process

Clearly we now know who this user is... a little bit over board.  Nevertheless, we know the user.  If for some reason you want a little more detail about a specific user then use the id command

id {username}

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...
Andrew Fletcher12 Mar 2024
How to determine the size of a directory in Terminal
To determine the size of a directory using the terminal, you can use the du (disk usage) command. The syntax for this command can vary slightly depending on the operating system you are using, but a common way to use it is as follows: For Linux and macOSdu -sh /path/to/directoryduDisk...