Different ways to get user and system information on Linux.

Posted: February 13, 2016. At: 8:03 PM. This was 2 years ago. Post ID: 8715
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

The who command on Linux and UNIX systems will list all currently logged in users on your system.

[email protected]:~$ who -Htu
NAME     LINE         TIME             IDLE          PID COMMENT
jason    :0           2016-02-13 13:43   ?          1895 (:0)
jason    tty2         2016-02-13 13:43 00:01        2164
jason    pts/0        2016-02-13 13:43   .          2178 (:0.0)

List all currently logged in users with the users command.

[email protected]:~$ users
jason jason jason

Another way to list all users currently logged in.

[email protected]:~$ w
 13:50:03 up 7 min,  3 users,  load average: 0.27, 0.49, 0.35
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
jason    :0       :0               13:43   ?xdm?   1:19   0.27s mate-session
jason    tty2                      13:43    6:20   0.19s  0.14s -bash
jason    pts/0    :0.0             13:43    3.00s  0.18s  0.00s w

Print the contents of the utmp file easily with the utmpdump /var/run/utmp command.

[email protected]:~$ utmpdump /var/run/utmp 
Utmp dump of /var/run/utmp
[2] [00000] [~~  ] [reboot  ] [~           ] [3.16.0-4-amd64      ] [0.0.0.0        ] [Sat Feb 13 13:42:24 2016    ]
[6] [00770] [tty1] [LOGIN   ] [tty1        ] [                    ] [0.0.0.0        ] [Sat Feb 13 13:42:49 2016    ]
[1] [00053] [~~  ] [runlevel] [~           ] [3.16.0-4-amd64      ] [0.0.0.0        ] [Sat Feb 13 13:42:58 2016    ]
[7] [01895] [:0  ] [jason   ] [:0          ] [:0                  ] [0.0.0.0        ] [Sat Feb 13 13:43:12 2016    ]
[7] [02164] [tty2] [jason   ] [tty2        ] [                    ] [0.0.0.0        ] [Sat Feb 13 13:43:34 2016    ]
[7] [02178] [/0  ] [jason   ] [pts/0       ] [:0.0                ] [0.0.0.0        ] [Sat Feb 13 13:43:58 2016    ]
[7] [02372] [tty3] [jason   ] [tty3        ] [                    ] [0.0.0.0        ] [Sat Feb 13 13:52:25 2016    ]
<pre>
 
Print information about your computers memory. The -gh parameter will print human-readable units in gigabytes.
 
<pre lang="bash">
[email protected]:~$ free -gh
             total       used       free     shared    buffers     cached
Mem:          5.7G       962M       4.8G        39M        40M       356M
-/+ buffers/cache:       565M       5.2G
Swap:         7.5G         0B       7.5G

No comments have been made. Use this form to start the conversation :)

Leave a Reply