Skip to content

Instantly share code, notes, and snippets.

@holmberd
Last active August 14, 2025 09:24
Show Gist options
  • Select an option

  • Save holmberd/b09fb15e9a49d60ac44ea7ff6fb1b6bb to your computer and use it in GitHub Desktop.

Select an option

Save holmberd/b09fb15e9a49d60ac44ea7ff6fb1b6bb to your computer and use it in GitHub Desktop.

Revisions

  1. holmberd revised this gist Aug 16, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions linux-kill-pts.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ### Kill user tty/pts sessions in Linux

    #### Commands

    - `w`: show who is logged on and what they are doing
  2. holmberd revised this gist Aug 16, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion linux-kill-pts.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    - `who`: show who is logged on
    - `tty`: show current users pseudo terminal
    - `ps -ft pts/1`: get process id for the pseudo terminal
    - `pkill`: signal process based on name and other attributes

    1. Check active users logged into the server with: `w`
    ```
    @@ -18,4 +19,6 @@ UID PID PPID C STIME TTY TIME CMD
    ubuntu 28580 28102 0 16:45 pts/1 00:00:00 -bash
    ubuntu 29081 28580 0 16:55 pts/1 00:00:00 ps -ft pts/1
    ```
    3. kill the process: `kill 28580`
    3. Kill the process: `kill 28580`

    4. Alternatively use `pkill -t pts/1`
  3. holmberd revised this gist Aug 16, 2018. 2 changed files with 21 additions and 6 deletions.
    21 changes: 21 additions & 0 deletions linux-kill-pts.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #### Commands

    - `w`: show who is logged on and what they are doing
    - `who`: show who is logged on
    - `tty`: show current users pseudo terminal
    - `ps -ft pts/1`: get process id for the pseudo terminal

    1. Check active users logged into the server with: `w`
    ```
    16:53:37 up 23:46, 2 users, load average: 0.00, 0.00, 0.00
    USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
    ubuntu pts/1 24.69.132.96 16:45 0.00s 0.04s 0.00s w
    ubuntu pts/2 24.69.132.96:S.0 16:35 16.00s 0.02s 0.02s /bin/bash
    ```
    2. Get the PID (Process ID) of a connected terminal (tty) with: `ps -ft pts/1`
    ```
    UID PID PPID C STIME TTY TIME CMD
    ubuntu 28580 28102 0 16:45 pts/1 00:00:00 -bash
    ubuntu 29081 28580 0 16:55 pts/1 00:00:00 ps -ft pts/1
    ```
    3. kill the process: `kill 28580`
    6 changes: 0 additions & 6 deletions ubuntu-kill-pts.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    #### Commands

    `w`: show who is logged on and what they are doing
    `who`: show who is logged on
    `tty`: show current users pseudo terminal
    `ps -ft pts/1`
  4. holmberd created this gist Aug 16, 2018.
    6 changes: 6 additions & 0 deletions ubuntu-kill-pts.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #### Commands

    `w`: show who is logged on and what they are doing
    `who`: show who is logged on
    `tty`: show current users pseudo terminal
    `ps -ft pts/1`