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

Comment

Webmentions

  • gay chat web cab room facebook

    easy gay chat https://gayinteracialchat.com/

  • gay chat rooms ring central

    chat gay almeria https://free-gay-sex-chat.com/

  • gay chat rooms free in illinois

    teen gay dick snap chat https://gaymusclechatrooms.com/

  • gay perv chat group

    old gay men video chat rooms https://gaychatnorules.com/

  • new york gay chat lines

    free gay cam chat https://gayphillychat.com/

  • gay chat rooms no registration needed

    gay live chat rochester video https://chatcongays.com/

  • gay adult phone chat

    skype gay chat https://gay-live-chat.net/

  • free seattle wa gay and bi mens chat sites

    dubuque gay chat https://gaychatspots.com/

  • gay web chat rooms

    gay video chat free https://gaychatcams.net/

  • gay sex chat online

    totaly free gay chat https://newgaychat.com/

  • casino streaming online

    new jersey online casino https://casinosonlinex.com/

  • pa caesars online casino

    online casino review https://online2casino.com/

  • lucky casino online

    online casino slots real money https://onlinecasinos4me.com/

  • amature dating co

    dating service https://onlinedatingservicesecrets.com/

  • connecting singles dating site

    best free online dating https://zonlinedating.com/

  • online dating 50

    skycouger gf https://virtual-online-dating-service.com/

  • dating sims free online japanese adult

    singles singles https://lavaonlinedating.com/

  • dating sites absolutely free

    mingle2 https://wowdatingsites.com/

  • date online site

    freedating https://datingpersonalsonline.com/

  • local-singles club

    international singles https://speedatingwebsites.com/

  • dating gmail germany

    new dating https://online-internet-dating.net/

  • top free dating sites

    pof dating https://adult-classifieds-online-dating.com/

  • freetalk45

    eris free downloads chatting apps https://adult-singles-online-dating.com/

  • matchmaking dating

    senior dating sites free https://onlinedatingbabes.com/

  • japanese dating sites

    single woman free https://freephotodating.com/

  • gay dating site crossword

    gay dating app windows https://datinggayservices.com/

  • best gay dating apps

    best dating website for gay man to pay for https://gayedating.com/

  • gay dating guam

    gay movie online dating https://gay-singles-dating.com/

  • best vpn for crypto trading

    proton vpn download https://rsvpnorthvalley.com/

  • best vpn for omegle

    best free vpn for ios https://free-vpn-proxy.com/

  • free vpn apk

    best vpn for porn https://superfreevpn.net/

  • business vpn setup

    best free vpn for macbook https://imfreevpn.net/

  • best vpn for macbook

    what is a vpn connection https://ippowervpn.net/

  • vpn review

    vpn torrent https://freehostingvpn.com/

  • free vpn canada

    hotspot vpn free download https://shiva-vpn.com/

  • vpn free pc

    free vpn for roobet https://freevpnconnection.com/

  • online casino us

    four winds online casino https://casino8online.com/

  • online casino vegas

    juegos de casino online https://all-online-casino-games.com/

  • casino games free online play

    online casino real money california https://ownonlinecasino.com/

  • online casino sign up bonus

    atlantic city online casino https://onlineplayerscasino.com/

  • online casino ideal

    zone online casino https://casino-online-jackpot.com/

  • casino online betting

    ocean online casino app https://casino-online-roulette.com/

  • parx casino online gambling

    riversweeps casino online https://vrgamescasino.com/

  • jumba bet online casino

    online casino with free signup bonus real money no deposit https://1freeslotscasino.com/

  • ocean casino online login

    online casino sweepstakes https://cybertimeonlinecasino.com/

  • free casino online games

    sugarhouse online casino pa https://internet-casinos-online.net/

  • michigan online casino no deposit bonus

    ocean online casino app https://free-online-casinos.net/

  • hollywood online casino

    pala casino online https://9lineslotscasino.com/

  • live blackjack online casino

    online casino with free signup bonus real money usa no deposit https://onlinecasinosdirectory.org/

  • riversweeps 777 online casino app

    casino in gta 5 online https://trust-online-casino.com/

  • las vegas casino online

    online casino sites https://newlasvegascasinos.com/

  • live casino online free

    online casino no verification withdrawal usa https://onlinecasinofortunes.com/

  • online casino games free

    caesar casino online nj https://firstonlinecasino.org/

  • online casino with no deposit bonus

    betfair casino online https://download-casino-slots.com/

  • how long is a dissertation paper

    uk dissertation writing help quotes https://customthesiswritingservices.com/

  • writing a doctoral dissertation

    write your dissertation https://dissertationhelperhub.com/

  • order a dissertation

    dissertation cover page https://dissertationhelpspecialist.com/

  • define dissertation

    nursing dissertation help https://writingadissertationproposal.com/

  • uf dissertation award

    dissertation template https://customdissertationwritinghelp.com/

  • phd dissertation peer reviewing help

    thesis vs dissertation https://businessdissertationhelp.com/

  • research writing help

    dissertation writing advice https://bestdissertationwritingservice.net/

  • phd without dissertation

    phd dissertation writing https://writing-a-dissertation.net/

  • dissertation writing grants

    proposal and dissertation help 2000 words https://examplesofdissertation.com/

  • dissertation writing service

    dissertation writing skills https://accountingdissertationhelp.com/

  • dissertation literature review

    chicago illinois dissertation help https://dissertationhelpexpert.com/

  • dissertation writing process

    writing methodology for dissertation https://dissertationwritingcenter.com/

  • help with dissertation topic

    proposal and dissertation help 2000 words https://helpwithdissertationwritinglondon.com/

  • writing tutor

    medical dissertation writing services https://professionaldissertationwriting.com/

  • help writing a dissertation

    dissertation help service quality https://professionaldissertationwriting.org/

  • 2helpfulness

    3advantage

  • 2carolina

    1reasons

  • get dissertation help

    writing dissertation aims and objectives https://helpon-doctoral-dissertations.net/

  • professional dissertation writing

    thesis and dissertation https://dissertations-writing.org/

  • write my dissertation uk help i can

    dissertation proposal sample https://mydissertationwritinghelp.com/

  • dissertation chapters

    thesis dissertation writing services https://help-with-dissertations.com/

  • dissertation writing services uae

    online cheap dissertation help https://dissertationwriting-service.com/

  • dissertation writing service

    help with completing dissertation https://buydissertationhelp.com/

  • hollywood4fun slots

    slots inferno https://slotmachinegameinfo.com/

  • wizard of oz slots

    myvegas slots facebook https://www-slotmachines.com/

  • nasty slots

    online slots real money https://411slotmachine.com/

  • reel deal slots

    igt slots https://download-slot-machines.com/

  • common expansion slots

    how to win at slots https://beat-slot-machines.com/

  • my vegas slots

    ff7 cait sith slots limit https://slot-machine-sale.com/

  • son and moon slots

    triple diamond slots https://slotmachinesforum.net/

  • las vegas world slots free

    play free bonus slots https://slotmachinesworld.com/

  • innovative slots

    free classic slots https://pennyslotmachines.org/

  • vegas downtown slots

    free slots for pc https://candylandslotmachine.com/

  • scatter slots by murka

    888 free slots machine https://freeonlneslotmachine.com/

  • slots free online

    slots of vegas casino https://2-free-slots.com/

  • gay dating fargo nd

    gay dating online https://speedgaydate.com/

  • local gay sex chat

    transcript of a man’s first gay chat https://gay-buddies.com/

  • local gay chat rooms

    chicago gay chat rooms free https://gaytgpost.com/

  • gay bear dating sites

    torrington ct gay dating https://gaypridee.com/

  • dirty gay sex chat

    gay chat aveneu https://bjsgaychatroom.info/

  • gay dating sites yahoo answers

    single gay dating site https://gaysugardaddydatingsites.com

  • gay dating search for free

    dinner for eight gay dating https://gayfade.com

  • fat chub gay dating

    chubby gay mens dating sites https://speedgaydate.com

  • boomerang gay dating

    feminine gay dating sites https://gayprideusa.com

  • college gay dating site

    gay dating app for over 50 https://gay-buddies.com

  • gay dating sites for kids 10-14

    gay addiction dating apps https://gaypridee.com

  • 2warship

    1vibrators