1.

Which command is useful to find current user information in Linux/Unix?

Answer»

To find out which users are currently LOGGED in to your server or system, use the who command. The who command provides the following information:

  • Last system boot TIME
  • Current system run-level
  • List of users logged in, etc.

Syntax: 

$ who [options] [filename]

Examples:

  • No Option: If no option is specified, the who command DISPLAYS the following information for each user currently logged on to the system:
    • The user's login name
    • The user's login time
    • The user's REMOTE hostname
    • Terminal LINE numbers

Command

$ who

Output

user@host-0231:~$ whogourav pts/0 2021-03-10 17:04 (:0.0)sonia pts/1 2021-03-10 18:23 (:0.0)
  • Option H: This option displays the headers of columns displayed by the who command.

Command

$ who -H

Output

user@host-0231:~$ who -HNAME LINE TIME COMMENTgourav pts/0 2021-03-10 17:04 (:0.0)
  • Option whoami: This displays the actual username of the system.

Command

$ whoami

Output

gkuser@host-0231:~$ whoamigkuser


Discussion

No Comment Found