Some fun with terminals : script and screen tools
By keefaz at 2005-03-05 10:52
There are two tools that can be usefull when working in console :
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 :
- On another terminal (or more), type :
script -f 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
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
All times are GMT -5. The time now is 01:39 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.