Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I need to open different processes or terminals that I need to check, I just open a new tab in my terminal and use different workspaces in my machine to keep everything organized.

I do some web development, using a Linux machine. I've seen that a lot of people use screen to accomplish what I'm doing, but I can't see any advantage. In fact, I thought it would be worse since now I have to remember all states in screen instead of having some terminals in a workspace named "terminals".

What am I missing? How do you actually use screen?

share|improve this question
9  
In addition to the real answers below, bear in mind that many Unix users developed their habits before tabbed terminals windows existed. Many of us even worked without a graphical environment, at least part of the time. People tend to stick with their habits, even as new options arise. –  coneslayer Feb 7 '11 at 18:52

8 Answers 8

up vote 28 down vote accepted

I use screen both locally and remotely. I find that I use screen because it gives me the ability to

  • Run multiple tasks without making multiple ssh connections to a remote server,
  • Run a long-running task in screen, detach, disconnect. The job will still be running in screen and I can come back later, reattach, and check its progress.
  • Have a more or less persistent workspace on a server, which is nice when I am doing something that involves multiple steps over the course of a day.
  • Receive important system information in a non-intrusive way using the screen profile customizations provided by byobu.
  • Use "Named Tabs": In screen I can give each "tab" in screen a name, allowing me to instantly know where to switch to.
  • Use more keyboard shortcuts. If you do most of your work at the computer, not having to use the mouse is a real plus. I find that screen's keyboard shortcuts provide a bit more power, but this may just because I've never invested in truly learning all of the GTK shortcuts.

Here is a screen shot of a recently started screen session using byobu and other customizations: Screen using Byobu

share|improve this answer
    
Hum, so you do just one ssh command to a remote server, and then run screen in this same ssh session? –  Somebody still uses you MS-DOS Nov 16 '10 at 18:37
    
Yes. The screen shot is my local screen, but I have a similar set up on the servers I need to use regularly. Basically, I (1) open a terminal, (2) ssh to the server, and then (3) immediately start screen. –  Steven D Nov 16 '10 at 18:40
    
Another useful function is windows splitting in screen. To split window horizontally press C-a S and after that you can switch focus to another window using C-a Tab. –  pbm Nov 16 '10 at 18:44
1  
Next time you take a screenshot and tries to erase some text from the window, remember that your terminal is transparent, and we can see the Gimp window behind it. ;) –  Denilson Sá Dec 29 '10 at 15:23
    
@Denilson Sa: Good call. –  Steven D Dec 30 '10 at 1:49

It's particularly useful when you don't have access to a graphical environment. For example, when you're on an ssh connection with no X11 forwarding.

share|improve this answer

I know people that use screen as a tabbed console; I don't. It's very useful if you want to leave interactive programs open without actually having a console connected all the time, especially if you want to be able to access those programs from multiple computers over SSH. For example, I keep my IM client open in a screen session on a server, so I'm always online, and I can connect to it from whatever computer I happen to be on

share|improve this answer

Heck yes! Screen (along with synergy) is one of my favorite programs. I use it every time I connect to our servers, and often just on my local machine.

Beyond what others have already mentioned, screen protects you from blips in network connections. When I'm working remotely (coffee shop, airport, etc) our VPN doesn't always play well with some networks. The VPN will disconnect and reconnect often. Using screen protects what you're working on from getting lost if one of these blips happens at a bad time.

Regarding 'remembering all the states', it helps to set up a status bar. In my .screenrc file, I have the following (among other stuff)

hardstatus alwayslastline
hardstatus string '%{= kw}[ %{= kb}%H%{= kw} ][%= %{= kw}%?%-Lw%?%{= kW}%n%f %{b}%t%{w}%?%?%{= kw}%?%+Lw%?%?%= ][ %{r}%l%{w} ]%{w}[%{r} %d/%m/%y %C%A %{w}]%{w}'

This shows details about where I am, which tab I have open. I will name my tabs based on either what server that tab is connected to, what folder I'm in, what process/script is currently running, or what file I have open.

share|improve this answer

Down to basics: it allows you to detach session and "transfer" running cli apps from one env to another (you can use the same irssi client in X and then in tty4 without closing irssi and reopening session in it). I find pretty annoying to have to reopen programs when i transfer some work and running apps from Xorg server to cli env (ttyX terminals). This way i just type

screen -R

and voila: my vim session, my moc playlist, my alpine mails, my last used dir in mc, my rss reader etc. are loaded in my terminal in a blink ov an eye without any reconnection or re-authorization.

share|improve this answer

Yes, screen is useful. Here's why in 8 easy steps:

  1. ssh you@somehost
  2. screen
  3. start doing something really important
  4. unplug the router / turn off the power in the building / spill coffee on your laptop (etc[*])
  5. panic
  6. get things back up an running
  7. ssh you@somehost
  8. screen -d -r
  9. continue doing what you were doing before #4

Ok, so that's 9 steps, but... you get the idea. screen is also great for all the other things people have mentioned, as is tmux, a BSD licensed alternative that is somewhat new to the game.

[*] here, etc refers to anything not involving the host you initially ssh'd to. screen isn't that good.

share|improve this answer

There are other cool features of screen including multiuser screen sharing and screen logging. For example if you're trying to train new person on some particular task you can have them connect to your screen session or connect to theirs and then you can watch each other type. If you see them making a mistake you can make the change directly on the command line while they watch. It's very helpful.

Screen logging can record the whole session so if the trainee wanted to review what he did he could watch/read it again. This can also be very useful if you have a guest consultant working on your system as it allows for review of their work.

share|improve this answer

Yes, it's extremely useful like others have explained.

Also, don't forget other similar tools like Tmux, which lets you share terminals more easily than screen, and also lets you split horizontally and vertically.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.