Basic of screen command

What is screen command

The screen command is used to run the script or command in the background, basically multiple full screen terminals from one shell, we can run the multiple commands in the screen.The screen command is useful while we are running the script or command which require the excessive time and we can’t stay online for such long time. for example we are running the server scan process which is required more then 1 day time to complete the process at that time, we can use the screen command to complete the task.

Login in the shell and install screen command by using the following command.

yum install screen -y

To open the screen session, run the screen command,once new session open you can execute the command.

screen

For example we are scanning the /home partition for the infected files but /home partition having more 26000 files therefore it will take time, so that you can close the screen session by using the CONTROL+a+d button, it will detached the screen session.

We can check the screen session ids by using the following command, so that we can easily reconnect the screen session to check the result for the command we have run in the screen

In above image the “22297.pts-0.linux” is a screen id therefore we can reconnect the screen by using the following command.

screeen -rd 22297.pts-0.linux

To terminate the screen , refer the CONTROL+D button.

 

About Anant 386 Articles
Senior technical writer