How To Use Screen And Script Command In Linux

April 23, 2011 | By
| Reply More

The screen is a terminal multiplexer. Using this, you can run any number of console-based-applications, interactive command shells, course-based applications, etc. You can use screen to keep running program after you accidentally close the terminal, or even after you log out and later resume right wherever you are. You can start screen just by typing screen at command prompt. You will be greeted by a welcome message.

Example: 1

[root@localhost ~]# screen

This screen command will start a new window within the screen.

Example: 2

[root@localhost ~]# screen -S aloft 1

The above command will start new window within the screen and also gives name of the window (aloft).

Example: 3

[root@localhost ~]# screen -ls

The above command displays current open screens including those running in the background.

Example: 4

[root@localhost ~]# screen mc

The midnight commander program will appear.

Example: 5

[root@localhost ~]# screen Top

The top program will start and display output to the command line.

Linux Script Command

This script command is very helpful for system admin. If any problem occurs to the system, it is very difficult to find what command was executed previously. Hence, system admin knows the importance of this script command. The script command keeps action log for various tasks. The script records everything in a session such as things you type, things you see and also records color.

Example: 1

[root@localhost ~]# script
Script started, file is typescript

By default, it writes to a file called typescript in the current directory. After completion of your task, you can enter exit. This will close down the script session and save the file.

Example: 2

[root@localhost ~]# script -a
Script started, file is typescript

-a appends the output to file or typescript retaining their previous contents.

Example: 3

[root@localhost ~]# script -q

-q runs the script in the quite mode.

Filed Under : HOWTOS, LINUX COMMANDS, LINUX HOWTO

Tagged With :

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.