How can I check who is logged on my Linux system?
Linux is an extraordinary operating system, which lets the user record every single process running on it. Today, we are going to show some thrilling commands, using which you can track “who is logged on my Linux system”. This tutorial will be very useful for administrators and novice users to Linux.
who is logged on my Linux system.
1. command “w”
w displays information about the users currently on the machine, and
their processes.
ubuntu@ip-172-31-12-106:~$ w 17:50:41 up 16 days, 1:09, 4 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ubuntu pts/0 124.253.84.169 17:39 1.00s 0.04s 0.00s w ubuntu pts/1 124.253.84.169 17:48 58.00s 0.03s 0.01s sshd: ubuntu [priv] vikas pts/2 124.253.84.169 17:50 39.00s 0.04s 0.04s -bash linuxtog pts/3 124.253.84.169 17:50 5.00s 0.04s 0.04s -bash
The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
- User – Displays the name of the user currently logged in the system.
- TTY – The Terminal number of a user.
- FROM – The IP Address of user.
- LOGIN@ – Login Time of a user.
- IDLE – The Free time after the execution of the last command performed by a user.
- JCPU – The JCPU time is the time used by all processes attached to the tty.
- PCPU – The PCPU time is the time used by the current process, named in the “what” field.
- WHAT – Current process executed by a user.
Examples of “w” command with various options.
- -h, –no-header (Don’t print the header.)
ubuntu@ip-172-31-12-106:~$ w -h ubuntu pts/0 124.253.84.169 17:39 8:33 0.04s 0.00s man w ubuntu pts/1 124.253.84.169 17:59 1.00s 0.03s 0.00s w -h vikas pts/2 124.253.84.169 17:59 12:57 0.03s 0.03s -bash linuxtog pts/3 124.253.84.169 17:59 12:36 0.04s 0.04s -bash
- -s, –short (Use the short format. Don’t print the login time, JCPU or PCPU times.)
ubuntu@ip-172-31-12-106:~$ w -s 18:14:12 up 16 days, 1:32, 4 users, load average: 0.10, 0.09, 0.06 USER TTY FROM IDLE WHAT ubuntu pts/0 124.253.84.169 10:12 man w ubuntu pts/1 124.253.84.169 3.00s w -s vikas pts/2 124.253.84.169 14:36 -bash linuxtog pts/3 124.253.84.169 14:15 -bash
2. command “last”
The command “last” displays a list of all users logged in and logged out of the system with their username, IP Address used for login, Date and Time, and also specifies the duration of session by a particcular user. All these details are stored in the file /var/log/wtmp and “last” searches back through the file /var/log/wtmp.
ubuntu@ip-172-31-12-106:~$ last linuxtog pts/3 124.253.84.169 Thu Sep 21 17:59 still logged in vikas pts/2 124.253.84.169 Thu Sep 21 17:59 still logged in ubuntu pts/1 124.253.84.169 Thu Sep 21 17:59 still logged in linuxtog pts/3 124.253.84.169 Thu Sep 21 17:50 - 17:54 (00:03) vikas pts/2 124.253.84.169 Thu Sep 21 17:50 - 17:54 (00:04) reboot system boot 3.13.0-113-gener Tue Sep 5 16:41 - 18:47 (16+02:06) ubuntu pts/0 27.255.166.137 Mon Sep 4 04:04 - 05:06 (01:02) wtmp begins Mon Sep 4 04:04:11 2017
3. command “last reboot”
The command “last reboot” will show a log of all reboots. It also fetches the data from the file /var/log/wtmp.
ubuntu@ip-172-31-12-106:~$ last reboot reboot system boot 2.6.32-642.15.1. Wed Sep 6 17:56 - 18:53 (15+00:57) reboot system boot 2.6.32-642.15.1. Tue Aug 22 17:52 - 16:49 (13+22:56) reboot system boot 2.6.32-642.15.1. Fri Mar 31 13:27 - 17:07 (144+03:40) reboot system boot 2.6.32-642.15.1. Fri Mar 31 13:17 - 13:26 (00:09) reboot system boot 2.6.32-642.15.1. Fri Mar 31 13:13 - 13:16 (00:03) reboot system boot 2.6.32-573.18.1. Fri Mar 31 12:59 - 13:12 (00:13) wtmp begins Fri Mar 31 12:59:28 2017
We are coming to an end. Using above command we can track “who is logged on my Linux system”. We hope this tutorial will be helpful for all the viewers. Stay tuned for upcoming posts. Gooday!
Nice information
Hello.
I didn’t found a contact form in your web, so I’ll ask a question here. Under what license are the content published in this blog?
Thanks
Its published under CC license.
thanks!
ND means that I can’t translate an article if I found it interesting? 🙁
anyway good stuff here!
Please email me on vikasmunjal25@gmail.com with the purpose. We can talk further on this.