Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community of people that helps each other.

If you are beginner in IT field, you are more then welcome to ask questions, it will help you to learn faster. We are here to help you.

We are always beginner in something, we just need to remember it along the way.

there are no wrong questions - Ask Question

Linux screen - most useful commands with practical examples

0 contributions
3 points

In this article we are gonna have a look at most useful linux screen commands. Most of the time we just need a few screen commands to get the job done. Below we have a lot of them.

Why screen is useful?

If we run some program from command line and our terminal will shutdown (internet problem, lack of energy) we can't go back to that session. Especially if we run some important installation or download some large file via ssh from another server. It is important to have backup and run this with screen or nohup.

Installation of screen command

  • If we have debian or ubuntu:
apt-get install screen
  • If we have centos:
yum -y install screen

Most useful commands

  • screen create new session
screen -S my_first_screen_session
  • screen detach press keys (in this order - first ctrl, second a, third d)
ctrl + a + d
  • screen list all sessions
screen -ls

Usage example:

root@mail:/# screen -ls
There is a screen on:
        21173.my_first_screen_session   (03/27/2020 09:54:27 PM)        (Detached)
1 Socket in /run/screen/S-root.
  • screen connect to detached session (21173 - id of screen session - NOT ENTIRE NAME, just ID), we can get id by using screen -ls
screen -r 21173
  • screen kill session (21173 - id of screen session - NOT ENTIRE NAME, just ID)
screen -X -S 21173 quit

Usage example:

[detached from 21173.my_first_screen_session]
root@mail:/# screen -ls
There is a screen on:
        21173.my_first_screen_session   (03/27/2020 09:54:27 PM)        (Detached)
1 Socket in /run/screen/S-root.
root@mail:/# screen -X -S 21173 quit
root@mail:/# screen -ls
No Sockets found in /run/screen/S-root.

 

0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more