Users Last Time of Login Bash Script Linux Vim
Have you ever been curious nearly who is logged in to your Linux system? You can always list all the users on your Linux arrangement but not all of them would be logged in all the time.
If you lot are on a multi-user Linux environment like a Linux server, checking logged in users could be useful and fun at the same fourth dimension.
In this tutorial, I'll show you various means you lot listing logged in users in Linux.
4 Commands to see logged users on Linux
Almost all these commands rely on the data stored in the /var or /proc directory. If you know a little near the directory structure in Linux, you know that these two directories contains information nigh the running processes on your system.
i. Utilise w control to encounter logged in users in Linux
Can information technology go any simpler than this? But type a unmarried letter of the alphabet control in the terminal and it will show the currently logged users in Linux.
due west
And here is the output for the westward command:
[email protected]:~$ due west 09:54:54 upward 26 min, 3 users, load average: 0.00, 0.00, 0.00 USER TTY FROM [email protected] IDLE JCPU PCPU WHAT root pts/0 202.91.87.114 09:37 21.00s 0.00s 0.00s -bash abhi pts/1 202.91.87.114 09:47 0.00s 0.00s 0.00s w rohini pts/2 157.43.53.142 09:48 6:13 0.00s 0.00s -bash
Let me explain a few terms in the output of the due west command. The same terms would exist used in other commands too.
TTY gives you data about the terminal used to log on. pts ways pseudo terminal slave which indicates that the user logged in via SSH connection.
Information technology shows the IP address of the user's computer, login time. You tin also see for how long a user has been idle (slacking at piece of work? :D).
JCPU is the time used past all processes attached to the TTY and PCPU is the time used by the current process running past the user. You can encounter this current process under WHAT column.
2. Check who is logged in with who command
Who command is some other simple 1. But blazon who and it will show who is logged on to your Linux system currently.
who
You can also see the login time and the IP accost of the logged on user.
[email protected]:~$ who root pts/0 Aug 6 09:37 (202.91.87.114) abhi pts/1 Aug 6 09:47 (202.91.87.114) rohini pts/2 Aug vi 09:48 (157.43.53.142)
3. Merely go logged in users with users command
All the commands yous saw and then far give you a lot of information about the logged in users. If you are working on a script and want to know simply the name of the logged in users, parsing the output of those commands would be an additional and somewhat complicated task.
This is where the users control can assist you. This command only outputs the logged in users, zippo else.
[email protected]:~$ users abhi rohini root
4. Using finger command to see logged in users
You may need to install finger control first considering not all Linux distributions have it installed by default.
It is bachelor in the universe repository of Ubuntu and you can install it with this command:
sudo apt install finger
Once installed, just blazon finger in terminal:
finger
And y'all'll see who is logged in on your Linux system.
[email protected]:~$ finger Login Name Tty Idle Login Time Office Part Phone abhi Abhishek pts/1 Aug 6 09:47 (202.91.87.114) rohini Rohini Rachita pts/2 xiii Aug 6 09:48 (157.43.53.142) root root *pts/0 Aug six 09:37 (202.91.87.114)
Bonus Tip: see who logged on your organisation since concluding reboot
What y'all saw so far was almost the currently logged in users. How would you know if a user logged out?
The terminal command in Linux gives you data well-nigh all the users who logged in to the arrangement since last reboot. It will also evidence the log in and log out fourth dimension of the logged out users.
concluding
Here'south the output of the final control which is self-explanatory I believe.
[email protected]:~$ last rohini pts/three 157.43.53.142 Tue Aug half-dozen x:05 - ten:05 (00:00) rohini pts/2 157.43.53.142 Tue Aug 6 09:48 still logged in abhi pts/ane 202.91.87.114 Tue Aug 6 09:47 still logged in root pts/0 202.91.87.114 Tue Aug 6 09:37 still logged in reboot system kicking four.fifteen.0-52-generi Tue Aug half-dozen 09:28 nevertheless running wtmp begins Tue Aug 6 09:28:43 2019
I hope this quick tutorial helped you in finding the users currently logged on to your Linux arrangement. If you know some other way to practise it, please share your play a joke on with us in the comment section.
Users Last Time of Login Bash Script Linux Vim
DOWNLOAD HERE
Source: https://linuxhandbook.com/linux-logged-in-users/
Posted by: acc1knewstoday.blogspot.com
comment 0 comments
more_vert