Description

This article discusses the different options to log out sessions manually, with a specific scenario where the same user is logged in simultaneous sessions.

Solution

Sessions can be logged out or closed on the basis of PID [process ID], terminal, or username. All sessions of the same user can also be logged out by using the <user> all option. These options are mentioned below: 

root@device> request system logout ?
Possible completions:
  <[Enter]>            Execute this command
  all                  Logout all sessions owned by user
  pid                  Management process ID for user
  terminal             Terminal user is logged in to
  user                 Name of user
  |                    Pipe through a command

Sometimes, the same user may open simultaneous multiple sessions. These sessions share the same username. The fastest method to log out these sessions is by using the terminal option.

Example

  1. Get the list of active sessions logged-in to the device by using the command show system users . Then select the terminal session that you want to log out manually. 

root@device> show system users                       
 8:11PM  up 16 days,  9:11, 4 users, load averages: 7.35, 7.19, 7.36
USER     TTY      FROM                              LOGIN@  IDLE WHAT
root     v0       -                                29Aug20 7days cli           
root     pts/0    10.107.106.42                    8:11PM      - -cs           
root     pts/1    10.107.106.42                    8:09PM      - cli           
root     pts/2    10.107.106.42                    8:09PM      2 cli           
  1. Notice the TTY value for the session to manually logout. The session is logged out by using the command request system logout terminal <TTY Value>

root@device> request system logout terminal pts/0 
logout-user: done
  1. The selected session is logged out.

root@device> show system users                       
8:16PM  up 16 days,  9:16, 3 users, load averages: 7.56, 7.29, 7.34
USER     TTY      FROM                              LOGIN@  IDLE WHAT
root     v0       -                                29Aug20 7days cli           
root     pts/1    10.107.106.42                    8:09PM      - cli           
root     pts/2    10.107.106.42                    8:09PM      6 cli 

This is applicable to all devices running Junos OS. For further details, refer to the command reference guide for request system logout .

Modification History

2021-12-31: Modified synopsis to address feedback; provided correct usage of " all " keyword because it was incorrect earlier; other minor non-technical edits

2025-01-29: Added SRX series to categories