Archive

Posts Tagged ‘screen’

.screenrc

October 9th, 2009 6 comments

I presented earlier today at the Utah Open Source Conference and briefly demoed some of the use cases for screen. During the presentation I had a number of requests for my .screenrc file, so I thought I would attach it here. If you use screen for any reason you might find this useful.

Download

## general tweaks
vbell off
autodetach on
startup_message off
defscrollback 1000
attrcolor b ".I"
termcap xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
#term screen-256color


## apps I want to auto-launch
#screen -t irssi irssi
#screen -t mutt mutt

## statusline, customized. (should be one-line)
hardstatus alwayslastline '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}[%{W}%n%f %t%?(%u)%?%{=b kR}]%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]%{=b C}[ %D %m/%d %C%a ]%{W}'

Categories: Linux Tags: , ,

Group Collaboration With Screen

May 17th, 2007 3 comments

This week I’m teaching out in Portland, OR in a Linux Fundamentals class. A small part of one of this weeks chapter is on screen. You might remember I’ve talked about screen in the past here. I still use screen on a day to day basis and really enjoy it. Today I’ve got something new for it that you may not have ever used.

Screen will allow you to collaborate within a session for multiple assigned users. It is also configurable to allow for read-only or read-write access on a per user basis. This, of course, if helpful if you don’t trust certain people within a collaboration as everyone will have input permissions on the screen.

Now the first step is that you’ll need to, at least temporarily, put the suid bit on the command screen. This is done using:

sudo chmod u+s /usr/bin/screen (multiuser screen below will not work without this)

Second you’ll want to create your initial screen session. You can do that (remember my original screen cheat-sheet) using a command similar to:

screen -S screen-name (naming your screen sessions with -S makes organizing and switching simpler)

Third you now allow the collaborator to connect to your machine using something like ssh.

ssh user@remote.machine

The fourth step is to set multiuser mode on within screen itself. This is done using the screen shortcuts followed by :multiuser on. Here is an example:

ctrl-a :multiuser on

You also need to explicitly allow permissions for the collaborating user (the one that ssh’d to the machine) using something like:

ctrl-a :acladd username

At this point username can connect to the shared screen using:

screen -x username/screen-name

If you want to just try it out you can test sharing screens by just using the same user account. Start screen locally using step two above. After that is up start some command or type something at the prompt. At this point open a second terminal window and type screen -x. You should have a mirror window in both terminals.

If you have any other implementations of this I’d love to hear about them. I really like this feature and can see a number of uses for it. Perhaps collaborating on code and not needing to use pastebin or something similar. Actually watching the other user work to show you examples.

It’s like remote desktop or VNC, minus the bandwidth and overhead!

Command line collaboration brought to you by GNU. What more could you want?

More permissions on advanced permissions here.

Categories: Linux Tags:

Command-Line Multitasking with Screen

Screen.  What can I say about it?  It’s not very well known to many people I mention it to but its one of those programs that you just can’t stop using once you’ve started.  Yes, I use screen on a regular daily basis and it’s really easy to use.

I know someone who says the only reason they invented X was so that you could use more virtual terminals.  I think the real solution behind great command line multitasking is screen!

Here are some basic usage tips.  To start a command line based program within a virtual ‘screen’ prefix that command with screen, such as:

screen irssi

Once that has loaded you can detach the virtual screen for later use by pressing ctrl-a d.  To reattach that screen type screen -r (or, if the screen was somehow not completely detached previously you would use screen -dr).

Now, ok, I can start applications within screen and detach them.. that’s cool I guess but couldn’t I just background the process or something similar?  I suppose so, but here is where it gets interesting.

Create a new screen instance within screen with ctrl-a c.  Do this as many times as you might need, based on the number of apps you’re using.  To later switch between these screens use ctrl-a 0-9, ctrl-a n,p (for next or previous) or to see a visual list, use ctrl-a “.

To close a screen you no longer need you can simply type exit which will take you to the next screen or exit screen completely if it is the last one.

In my setup I’m running irssi, mutt, bash and snownews within screen 0-3 over ssh to a private server at home.  On my local machine I load screen for rtorrent and an irssi notification script.  Once I get them both going I ctrl-a d, close gnome-terminal and don’t bother with those apps until I need something. At that point I screen -r and there they are again, right back where I left them.. and having continued that whole time.  Like I said, easy multitasking on the command line.

Do you have any magic screen tips to share with the crowd?  You know where the comments go.

Categories: News Tags: ,