[LINUX NOTES] Take your shell with you everywhere – we all SCREEN for I SCREEN

This week I’ll improve my usage of screen and look up byobu too. Here are some reasons why.

TABS IN THE COMMAND LINE

Modern browsers have used us to the concept of tabs. Interactive web sites are full of tabs. Why not have them also in the shell? With screen and byobu you can.

BETTER SCRIPTING PRODUCTIVITY WITH TABS

You can write your script in one tab and execute it in another after every modification! And in tab 0, for example, you can keep the tail -f of the apache error log when you are developing web applications. You can keep different logs in different tabs and monitor stuff all over the place, even on other machines, as you go on.

MEMORIZE FEW COMMANDS OR CREATE YOUR OWN

There aren’t that many command to learn, and you can also bind your own keystrokes to actions in the screenrc configuration file.

SHELL THAT DOESN’T CHEAT, IT KEEPS WORKING EVEN IF YOU’RE NOT LOOKING

So, the shell continues working for you even if you’re not looking. You can dettach the screen on any remote machine as you leave the office and come back home, reconnect to the machine, and continue working from where you left off. You can leave a tail -f that scrolls files you want to keep track on. Or use watch (-d for colors that indicate changes, -n or –interval for interval).

IF YOUR HAVING CONNECTIVITY PROBLEMS

If you are having connectivity problems, broken pipes, ssh shells freezing on you, you certainly need screen, along with other measures. BTW look up nohup as well 🙂

ADVANCED MONITORING

“Just wanted to mention to other cool tricks you can do with screen. Screen can monitor a window for activity or lack thereof. This is great if you are downloading large files, compiling, or watching for output. If you are downloading something or compiling, you can watch for silence. To start the monitor, go to the screen you want to monitor and use “Ctrl-A” “M” to look for activity or “Ctrl-A” “_” to monitor for silence. Then open or switch to a new window. When the monitor detects activity or silence, you will get an alert at the bottom with the window number. To quickly go to that window, use “Ctrl-A” “ (thats a quote mark, ctrl-a then a “). After you do this, just type in the number of the window and enter. To stop monitoring, go to that window and undo the monitor with the same command. For example, to stop monitoring for activity you would use “Ctrl-A” “M” again.”

http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/

INVITE USERS INTO A SCREEN SESSION

An interesting teaching tool if you want to show someone how something is done in the command line. I still have to try that!

SCROLLING AND SEARCHING

You can’t do the usual shift and page up to scroll like in a normal shell, when in screen. But you can

http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/

CUSTOMIZE SCREEN WITH SCREENRC

“A typical application of this tidbit of knowledge is to launch a predefined set of windows at screen startup. Below is a sample screenrc that will do so:

# read in your normal screenrc
# before anything else
source $HOME/.screenrc
# now start opening windows
screen top
# it's possible to set the window title with
# the -t option
screen -t irc epic
# you can also specify the window number
# to launch in
screen -t mail 8 mutt
screen -t daemon 9 tail -f /var/log/daemon.log

If you save this to $HOME/.screenrc.multiwin you can tell screen to use it instead of your normal .screenrc by running screen -c $HOME/.screenrc.multiwin

http://www.linuxjournal.com/article/6340?page=0,1

I’ll write a separate post on that some day 🙂

More links:

http://www.kuro5hin.org/story/2004/3/9/16838/14935

http://www4.informatik.uni-erlangen.de/~jnweiger/screen-faq.html

http://www.softpanorama.org/Utilities/Screen/screenrc_examples.shtml

Advertisements

About apprenticecoder

My blog is about me learning to program, and trying to narrate it in interesting ways. I love to learn and to learn through creativity. For example I like computers, but even more I like to see what computers can do for people. That's why I find web programming and scripting especially exciting. I was born in Split, Croatia, went to college in Bologna, Italy and now live in Milan. I like reading, especially non-fiction (lately). I'd like to read more poetry. I find architecture inspiring. Museums as well. Some more then others. Interfaces. Lifestyle magazines with interesting points of view. Semantic web. Strolls in nature. The sea.
This entry was posted in tutorials, Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s