Skip to main content

Linux Screen Command Examples

 

 

Installing Screen

Linux screen command already installs on system. You can find screen command in /usr/bin/screen on most RHEL & CentOS distributions. You can find this out from which command in command line.
Source Code   
[root@linuxpathfinder ~]# which screen
/usr/bin/screen
If screen command is not install on server, you can install from redhat package manager (RPM) or with package file as show below:
Source Code   
[root@linuxpathfinder ~]# yum install screen
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.0.3-16.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package                  Arch                     Version                         Repository              Size
====================================================================================================
Installing:
screen                   x86_64                   4.0.3-16.el6                    base                   494 k
Transaction Summary
====================================================================================================
Install       1 Package(s)
Total download size: 494 k
Installed size: 795 k
Is this ok [y/N]: y
Downloading Packages:
screen-4.0.3-16.el6.x86_64.rpm                                                           | 494 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : screen-4.0.3-16.el6.x86_64                                                                   1/1
Verifying  : screen-4.0.3-16.el6.x86_64                                                                   1/1
Installed:
screen.x86_64 0:4.0.3-16.el6
Complete!

Starting Screen Command

As we put all commands on linux server command line, screen command is also started from it:
Source Code   
[root@linuxpathfinder ~]# screen
You will see that you have entered inside of a screen window. Now you can start your work as a normal command line environment. The screen application has its parameters.
Type “Ctrl-a” and “?” without quotes and see all parameters or commands in which guide you how to use screen.

Creating Screen Windows

After entering into screen you just use “Ctrl-a” “c” to create a new window in the default prompt and your old window will be still activated.
If you run any command in newly created screen window and after that switch to another window to do other things. Now you will see previous command in old window will be still running.

Switching Windows

“Ctrl-a” “n” screen command allows you to move forward and back. In the above creating window example to switch on screen window to other screen window, this command “Ctrl-a” “n” switches you to the next window. This command work like a circle around to your first window.
Command with “n” option forward to next window and command with “p” option move to previous window.
Each command in different windows will continue its process until you kill that window.

Detaching From Screen

While using screen command if you need to drop into actual shell. You have a detaching option to exit screen command with “Ctrl-a” “d”. This command has an option to reattach the previous screen. So that we can consider it the powerful part of the screen. For example, if you are using rsync command to copy server data to another server. I would recommend to run rsync command into screen to avoid break the session due to any reason. After detaching the screen your all windows will be still threr and safe.

Reattach Linux Screen

You have an option to reattach the screen. However you detach your connection from the screen or your connection lost due to network or some other reason.
Source Code   
[root@linuxpathfinder ~]# screen -r
Above command reattach to your screen.
If you have multiple screens you may get below message:
Source Code   
[root@linuxpathfinder ~]# screen -r
There are several suitable screens on:
27458.pts-0.linuxpathfinder    (Detached)
27447.pts-0.linuxpathfinder    (Detached)
Type "screen [-d] -r [pid.]tty.host" to resume one of them.
There are another option to see a single or multiple screens like:
Source Code   
[root@linuxpathfinder ~]# screen -ls
There are screens on:
27832.pts-0.linuxpathfinder    (Detached)
27899.pts-0.linuxpathfinder    (Detached)
2 Sockets in /var/run/screen/S-root.
Here you specify the screen if you have multiple screens.
Source Code   
[root@linuxpathfinder ~]# screen -r  27458.pts-0.linuxpathfinder

Logging Screen Output

As you are a Linux Administrator and manages many Linux servers like backups, configurations, taking logs etc. So sometime needs recording screen command logs. Let’s say you are using screen command activate with logging function, to activate logging function press “Ctrl-a” “h” . Now you do not need to put down even a single command which you did. When you activate logs function a notification tells you at the bottom left side of the screen. It creates logfile name “screenlog.0″ and save into your home directory.
Everything save into the logfile you write down in screen window. Press again same command to close screen to running log activity.

Getting Alerts on Screen

Another great feature of screen is to monitor a window for any activity. If you are waiting for output of your activity, something compiling or uploading/downloading large files, you can press “Ctrl-a” “m” to look for output at the bottom of the page of your activity.

Lock Screen Session

Lock the screen also have another feature of screen command specially when you need to step away from your system due to any reason. You just need to press “Ctrl-a” “x” shortcut to lock the screen. When you press the shortcut the output become look like as show below.
Source Code   
Screen used by root <root>.
Password:
Now use your Linux password to unlock it.

Leave/Exit Screen

There are two options to leave or exit the screen. First we detach the screen with “Ctrl-a”  “d” and the second option is to exit command to terminating session or use Ctrl-a”  “k” to kill the screen.
There are still a numerous features of screen command. We only discussed such features which are implement on daily basis.

Comments

Popular posts from this blog

The Best Web Hosting Services

Are you looking for the best web  hosting  services for your needs? Whether you need a place to host your small personal blog or a major corporate website, the following list will help you identify the best hosts to use. Finding the best web hosting service isn’t quite as straightforward as searching Google and choosing the one with the lowest price. There are a lot of issues to consider, including the reasons for  why  you need hosting and  how  you intend to use it. Once you have a handle on that, finding the right host becomes much easier. Choose one that’s undersized and you’ll end up with website outages and slow page loads, but choose one that’s oversized and you’ll be throwing money away. Defining Your Web Hosting Needs Before choosing your web host, you’ll need to think about your requirements. Consider the following concerns and decide the importance of each item on a scale of 0 to 10 (with 0 being not at all important and 10 being critically important): Speed  — H

Google Photos can now stabilize all your shaky phone camera video

G oogle Photos is where all my photos are. Long ago I was a man of SmugMug, and then Flickr, and then at some point spent days and days copying years of images to iCloud Photo Library before eventually disregarding that and switching to Google. What can I say? I’m a simple person who can be easily delighted and swayed by automatic GIF creation and reliable backups. And Google Photos keeps getting better. Here’s the latest example: now the mobile app can automatically stabilize videos in your camera roll with a tap. A lot of flagship smartphones offer optical image stabilization when shooting video, a hardware feature that helps keep footage smooth. Others, like Google’s Pixel, use software to try and stabilize jerky movements. Putting stabilization inside the Google Photos app could enhance results further if you’re already working with hardware OIS, or improve recordings significantly if your phone lacks any means of steadying things out of the box. The stabilized video is croppe