How to execute commands as another TTY user Linux

Have you ever wondered how to execute commands on your friends terminal without accessing his keyboard? Well now you can!!!


  • Root or Sudo access on your Linux machine
  • Debian or Debian based machine

Getting started

A fairly new low-key piece of open source software has surfaced recently and it allows users with sudo access on Linux to run commands on another TTY session!!! To begin, this software is called ttyecho, and you can download its source code which can be found on my Github Scripts repository (here –> note I did not make ttyecho.c) or it can be found at its original source here.

Getting ready

To begin, you will need to be able to compile C code on your Linux system and a few other system requirements, luckily I have already created a script that automatically checks to see if your system meets the requirements and if not installs them. To run this script you must first have it downloaded from my scripts repository on GitHub, to do so go here and simply copy and past the script into a file called Next, we must make the script executable for future use, we can accomplish this by running chmod u+x

Finishing up

Finally, we can begin finishing this setup by simply running my script. To do so, all we have to run is sudo ./, running my script as sudo will simply give it privileges to store your newly compiled version of ttyecho as a command…

Running the commands

After finishing the setup we can now run commands on another’s TTY session!!! Follow the steps below to run the commands:

  • First, find the TTY  you want to execute the commands as, to find the specific users terminal session please run
    ps aux | grep screen | grep $USER

    Note: Replace $user with the username


  • Next, look for the TTY, it should look something like pts/2, we will need this for the $YOUR_TTY in the next step
  • Finally, simply run sudo ttyecho -n $YOUR_TTY "echo test"

1 Comment

  1. NerdOfLinux says:

    Make sure you don’t use your own TTY! Just run tty in your current session to check yours before doing this.

Leave a Reply

Your email address will not be published. Required fields are marked *