Find the answer to your Linux question:
Results 1 to 8 of 8
I was wondering is there any way to send commands to terminals (bash sessions like /dev/pts/0) on which other users are logged in? For example I am on /dev/pts/1 and ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    14

    send commands to terminal other users are logged in

    I was wondering is there any way to send commands to terminals (bash sessions like /dev/pts/0) on which other users are logged in?

    For example I am on /dev/pts/1 and i want to send commands from that terminal to /dev/pts/0.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    I just tried it. You can echo a command to a terminal by typing e.g
    Code:
     echo -e "ls \n">/dev/pts/0
    but the command isn't actually executed.

    If on the other hand you type
    Code:
     ls>/dev/pts/0
    the command doesn't appear on the other terminal but the expected output does. Of course if the terminal belongs to someone else, you'd have to be root to write to it.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    If you are asking how you can remotely execute commands on another tty, the short answer is "you can't". The long answer is "you can, but not easily". I'd have to do some research since it has been a long time since I implemented a tool to do just that (on Unix systems). Effectively, it's a matter of inserting data into the tty's input buffer so that it thinks it has been typed by the user. Not simple to do, but possible for a root process. It might require a kernel module in Linux to accomplish, but at this point, I cannot say for sure.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  4. #4
    Just Joined!
    Join Date
    Jun 2007
    Posts
    14
    Thanks for reply.
    Root previliges are not an issue but it seems that echoing commands to another tty is not a feasable option.

  5. #5
    Just Joined!
    Join Date
    Jun 2009
    Location
    Toronto
    Posts
    18
    What about the 'write' and 'talk' commands?

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    All that echoing them does is display what you echo to them. It doesn't execute the command in their environment. To do that, you need to plug it into the input buffer of the tty they are using.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Just Joined!
    Join Date
    Jun 2009
    Location
    Toronto
    Posts
    18
    Quote Originally Posted by cgrebeld View Post
    What about the 'write' and 'talk' commands?
    Never mind, I see you want to execute not just echo to.

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Yeah. The biggest issue is hacking into the input stream of the user or tty. Remote desktop software does that, but the window server software is set up with a means to do that. If the user you are trying to "hack" is not running a x-server of some sort, such as just an ssh or telnet session, then it's a bit more difficult. Not impossible, but not simple either. Since I haven't done this for Linux I don't know if it would require a custom kernel module or if it could be done from user space entirely. In any case, it would be a tool to keep out of the hands of the "innocent"!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...