How to Force Kill a Screen Session Linux?

The multiplexer of the terminal is known as the screen. Every Linux user uses various tools to perform actions in the Linux operating system. Sometimes users can face some glitches and bugs that can clog the system screen, making it hard to close the software. Linux operating systems give the facility to force kill the screen session.

This article will demonstrate how to kill the created screen session in Linux.

How is the Screen Session killed in Linux?

In some scenarios, the user must create more than one terminal session. The benefit of using the screen is if the user disconnects or accidentally closes the current screen session, it will still run the process in the screen session. Let’s understand the method to force kill the screen session:

Syntax:

$ screen -X -S [session number] kill

Step 1: Listing a Screen Session

To list the created screen session in the Linux operating system, use the below-given command:

$ screen -list

The screen session will be listed. In our case, we have two screen sessions, “session_1” and “session_2”.

Step 2: Force killing a Screen Session

To kill a screen session in Linux, use the created session ID and then type the “kill” in the below command:

$ screen -X -S 3444 kill

The screen session will be killed.

Note: The “kill” option will kill the 1-screen window.

Step 3 (Optional): Quitting a Screen Session

To quit the entire screen session in Linux, give the session ID and type the “quit” at the end:

$ screen -X -S 3436 quit

The whole screen session will be closed.

Bonus Tip: How To Attach and Kill the Screen Session in Linux?

To attach and kill the created screen in Linux, use the “r” flag with the screen command and the screen session with its ID:

$ screen -r 4177.session_1

After typing the command, press the enter button, and it will take you to the created screen session.

Type the exit command and press Enter:

$ exit

Doing this, you will be exited from the current screen session, and the terminating message will be displayed:

$ screen -r 4177.session_1

The screen session has been terminated, as shown in the above image.

Conclusion

To force kill the screen session in Linux, use the “kill” option in the “screen -X -S [session_ID] kill” in the command or use “quit” to quit the entire screen session. This write-up has illustrated the methods to force kill the screen session in Linux. Apart from this, the method to attach and kill the screen session has also been demonstrated in this blog.