in linux, Tutorials

I administrate linux servers from time to time, and a common need in those situation is monitoring what a different terminal is doing. Either because of a lost connection to an SSH terminal which runs a command, or wanting to know what an unrecognized terminal is doing. To that end I use a very useful tool called strace.

Strace is a system utility on linux systems that can trace all systems calls and signals that a process uses. To monitor a terminal we can make strace print all occurrences of the read and write system calls that the terminal process is using.

Note: This tutorial assumes you have root privileges otherwise you won't be able to use strace to connect and monitor a running process.

To see who’s connected to the machine we can list /dev/pts. The directory contains special character files for each connected pts.

To use strace for the task at hand, we first need to identify the terminal we want to connect to. We can use ps which lists all the running processes like so:

alpha@milkyway:~$ ps aux | grep pts
alpha      943  0.0  0.0  44472  3344 pts/4    R+   09:23   0:00 ps aux
alpha      944  0.0  0.0  21536  1048 pts/4    S+   09:23   0:00 grep --color=auto pts
alpha     7978  0.0  0.0  29812  5172 pts/3    Ss+  09:16 0:00 bash
alpha    22659  0.0  0.0  29812  5192 pts/0    Ss   00:13   0:00 bash
root     22877  0.0  0.0  72716  4304 pts/0    S    00:24   0:00 sudo su alchemist
root     22878  0.0  0.0  72248  3884 pts/0    S    00:24   0:00 su alchemist
alchemi+ 22891  0.0  0.0  29808  5100 pts/0    S+   00:24   0:00 bash
alpha    23022  0.0  0.0  29812  5104 pts/1    Ss   00:28   0:00 bash
root     23034  0.0  0.0  72956  4424 pts/1    S    00:28   0:00 sudo su
root     23035  0.0  0.0  72248  3780 pts/1    S    00:28   0:00 su
root     23049  0.0  0.0  28712  3924 pts/1    S+   00:28   0:00 bash
alpha    24095  0.0  0.0  29812  5144 pts/2    Ss+  01:15   0:00 bash

To see all the input and output of the pts we’re interested in we can call strace with the following arguments:

strace -f -s999 -e trace=write -p 7978

-f: This option tells strace to follow the system calls for the child processes as well (commands run in the terminal).

-s: by default strace truncates strings, we can set the truncate limit higher so we can see more of the output.

-e trace=write: the system calls we want to monitor. For our task we only want to see the output in the terminal. If you want to log what the user types you can add the read call as well. The format is trace=syscalls1,syscall2,..

-p: The pid of the process we’re monitoring.


The output is useful, but it would be more useful if the output was more human suitable. You’re in luck, I wrote a simple wrapper to make the output appear like a normal terminal. You can download it from here.

Write a Comment



  • get dissertation help

    writing dissertation aims and objectives

  • professional dissertation writing

    thesis and dissertation

  • write my dissertation uk help i can

    dissertation proposal sample

  • dissertation chapters

    thesis dissertation writing services

  • dissertation writing services uae

    online cheap dissertation help

  • dissertation writing service

    help with completing dissertation

  • hollywood4fun slots

    slots inferno

  • wizard of oz slots

    myvegas slots facebook

  • nasty slots

    online slots real money

  • reel deal slots

    igt slots

  • common expansion slots

    how to win at slots

  • my vegas slots

    ff7 cait sith slots limit

  • son and moon slots

    triple diamond slots

  • las vegas world slots free

    play free bonus slots

  • innovative slots

    free classic slots

  • vegas downtown slots

    free slots for pc

  • scatter slots by murka

    888 free slots machine

  • slots free online

    slots of vegas casino

  • gay dating fargo nd

    gay dating online

  • local gay sex chat

    transcript of a man’s first gay chat

  • local gay chat rooms

    chicago gay chat rooms free

  • gay bear dating sites

    torrington ct gay dating

  • dirty gay sex chat

    gay chat aveneu

  • gay dating sites yahoo answers

    single gay dating site

  • gay dating search for free

    dinner for eight gay dating

  • fat chub gay dating

    chubby gay mens dating sites

  • boomerang gay dating

    feminine gay dating sites

  • college gay dating site

    gay dating app for over 50

  • gay dating sites for kids 10-14

    gay addiction dating apps

  • 2warship