Linux / UNIX find out what other users are doing?

Q. Can you explain the command to find what users are doing on my UNIX / Linux system?

A. Both Linux and UNIX (FreeBSD/Solaris) has w command to show who is logged on and what they are doing.

The w command prints a summary of the current activity on the system, including what each user is doing.

=> The first line displays the current time of day

=> How long the system has been running

=> The number of users logged into the system

=> The load averages. The load average numbers give the number of jobs in the run queue averaged over 1, 5 and 15 minutes.

You can also use ps command which shows you process that are running on the system.

Type w command displays information about the users currently on the machine, and their processes.

Show who is logged on and what they are doing with w command

The fields output are the user’s login name, the name of the terminal the user is on, the host from which the user is logged in, the time the user logged on, the time since the user last typed anything, and the name and arguments of the current process.
$ w

radm    pS     Sun01PM  1day -bash
raj     pW  7:42AM     5 ssh root@
miku    pX a80-186-82-84.el  7:28AM    10 screen irssi
vivek   pY    4:11AM     0 nano -w hireme
rani    q0    7:32AM    12 lynx
jadmin  q2    7:33AM     0 ssh
gad     q3   7:40AM     0 -ksh
bencs   q5   7:44AM     5 -zsh
vivek   q6      7:47AM    11 -bash

You can use the ps command shows you processes that are running on the system:

$ ps -au | more
$ ps -au | less

So you can use both w and ps commands to find out who’s doing what.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 10 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • vinod Jun 27, 2007 @ 11:48

    I want to know who all logged in and what files they have opened and modified

  • Keith Rose Jan 19, 2009 @ 6:45

    To vinod – Check the individual users .bash_history file. If they havent modified it, you will see all the commands they have executed.
    vi /home/USERNAME/.bash_history
    where USERNAME is the user who you want to check.

  • shailesh mishra Apr 16, 2009 @ 8:39

    Is there any way by which i can attach some terminal so that i can continually read that one ? What i want is that once i see on which terminal a user is logged in,i want to read that terminal so that i can ACTUALLY see whats that user is doing at that time.
    I am aware of screen command but i suppose it requires user action.I actually want to monitor a particular users action in real time.

    • Sabyasachi May 1, 2015 @ 23:34

      watch cat /home//.bash_history | tail -1

      where the user whose command you want to see.

  • daulat kumar May 15, 2009 @ 4:02

    anyone can tell me what is the actual process use w command in linux system to display system and user information

  • Prabhakar Raokhande May 20, 2009 @ 5:05

    I want to know PID of the terminal which user has logged in and closed the connection without logging out. When I fire Who I can see some terminal process but coud not get there PID to kill those process.
    Any one has idea how to find and kill these type of orphan process?

  • Denise Dec 5, 2009 @ 4:14

    How do i get more specific about the Process done?

  • bhuvana Feb 26, 2013 @ 5:01

    how can i know who are all accessing my file????

  • bhuvana Feb 26, 2013 @ 5:01

    how can i know who are all accessing my file in unix????

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum