Latest LQ Deal: Latest LQ Deals
Go Back > Linux Answers > Applications / GUI / Multimedia
User Name


By keefaz at 2005-03-05 10:52
There are two tools that can be usefull when working in console :
- script
- screen

1. script

script is a nice program that let you monitor in one or
more terminals what you type in another terminal.

- Open two X terminals in your X session or use the Linux
ttys (ctrl + alt + F1-6)

- On one terminal, type :
cd ~
mkfifo output
script -f output
- On another terminal (or more), type :
cd ~
cat output
- Then return to the first terminal and execute any
command you like (ls, cd, ping...)

The output should be appear on every terminals where
you cat output fifo.

- Exit script session by typing exit command in the first
terminal (the one which you started script command)

man script for more infos

2. screen

screen is a terminal screen manager (like a window manager
but for consoles)

- In a terminal, type : screen
screen is now started, it has opened one screen, you should
see the prompt of your shell, waiting for commands

- Name this screen with typing : [ctrl + a], then A (note that
A is uppercase, so you may need to type:
[ctrl +a], then [shift +a]
Erase the default title using backspace key and name it whith
any name you want, say "Shell 1", press <enter> key.

- Create a new screen with : [ctrl + a] [ctrl + c], name it
([ctrl + a], [shift + a]), say "Shell 2"

- To switch between these 2 screens, type [ctrl + a], then ["]
(double quote key), you should see a list of all your screens
To enter on one, just select it with the top/bottom arrow keys
and press <enter>

- To exit screen, just type exit in all your opened screens

Tips for ssh session :
Say you run a command that take long time to complete
(say updatedb or a system upgrade), you can detach your
screen, exit ssh session, let the command run on the
remote host and return to the screen later :

- ssh to your remote host, run screen, run your command,
then type : [ctrl + a], [shift + d], [shift + d]

You now are now logout of your ssh session, screen in
remote host is detached so it keep running your command

To return to your screen, ssh into your remote host, then
use : screen -r

You are now in the screen showing output of the command
you issued before.

man screen for more infos

by bdox on Mon, 2005-03-21 09:45
I read the article and I still when and how those programs can be useful...
explain the meaning of the commands would be nice too...

by Artanicus on Wed, 2005-06-15 03:35
um, isnt it ctrl+a ctrl+d to detach a screen, not ctrl+a shift+d shift+d ?
The latter might work too, but ctrl+d is alot more intuitive and handy.. (:


All times are GMT -5. The time now is 01:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration