I opened 4 terminals but when check them with who
or w
me@alpha:~$ w
17:28:19 up 3:09, 1 user, load average: 0.51, 0.35, 0.34
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
me :0 :0 14:20 ?xdm? 3:27 0.01s /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESS
me@alpha:~$ who
me :0 2019-01-16 14:20 (:0)
It display only one termianl called ':0'
if on macos it will display
me at mbp in ~
$ who
me console 2019-01-04 08:57
me ttys000 2019-01-04 08:57
me ttys001 2019-01-04 08:57
How could display all the terminal ?
The issue is due to how certain terminals work. In particular,
sakura
andgnome-terminal
(Ubuntu's default) which I have used before do not register the terminal. There is, in fact, a bug report for gnome-terminal, which is closed with WONTFIX status.Finding number of open terminal sessions, therefore, should be focused on finding parent processes of shell sessions or associated
pts
/tty
devices, as shown in this question:The only issue with this command is that it should display processes from all users. My personal approach would be to filter out my own processes ( i.e. terminals I opened myself ) via
-u
option and parse withawk
: