LWN.net Logo

My sysadmin toolbox (Linux.com)

Joe 'Zonker' Brockmeier lists his top ten software tools, on Linux.com. "The first time I read about GNU Screen, I thought it was a bit of a silly program. Why not just open a bunch of xterms, instead of mucking about with all the complex keybindings used by Screen to switch between its windows? Sure, it might be useful if you only work from the console, but how many folks really do that anymore? Then I actually spent a little bit of time with Screen, and I found out what a valuable utility it really is. Instead of worrying about dozens of xterms, I could have a single terminal window with multiple Screen windows that I could switch between easily and quickly."
(Log in to post comments)

Screen in an xterm?

Posted Nov 1, 2005 23:04 UTC (Tue) by BrucePerens (subscriber, #2510) [Link]

Tabs in GNOME Terminal seem to do the job.

Screen in an xterm?

Posted Nov 1, 2005 23:09 UTC (Tue) by allesfresser (guest, #216) [Link]

>Tabs in GNOME Terminal seem to do the job.

Well, yeah, unless you're, for example, working over a SSH connection to a server thousands of miles away and need to have more than one session open at once, and also might need to detach and come back at a later time without disturbing any of said sessions. Then screen can (and has!) come in right handy.

Screen in an xterm?

Posted Nov 2, 2005 0:42 UTC (Wed) by cantsin (subscriber, #4420) [Link]

Not to mention copy & paste between screen terminals [which I need all the
time, for example to copy a URL from elinks to vim], split
screens/terminals, monitoring of single terminals, remote screen sessions
within local screen sessions...

Screen in an xterm?

Posted Nov 2, 2005 13:01 UTC (Wed) by smitty_one_each (subscriber, #28989) [Link]

emacs with eshell?

tabs in gnome terminal

Posted Nov 1, 2005 23:13 UTC (Tue) by stuart (subscriber, #623) [Link]

Bruce.....I can't believe you have not used screen so presume this is a troll! A large advantage of screen is that you can detach from your "tabbed gnome terminal" and reattach to it via ssh or two people can be attached simultaneously -- a little like vnc.

irssi (an IRC client) run in screen on a reliable server is brilliant, you just switch off your laptop for the night and the following morning, reconnect to your screen session with no IRC conversations lost and no reconnection hassle.

Also tabs in screen don't make the window grow or shrink and hence upset all my applications (gnome terminal is really good for hitting Ctrl-L lots).

Anyway I have either fed the troll or discovered an Open source luminary who doesn't grok screen.

Stu.

tabs in gnome terminal

Posted Nov 1, 2005 23:42 UTC (Tue) by BrucePerens (subscriber, #2510) [Link]

Stuart,<p>I have used a program called "screen" on various Unix systems, mostly in the late 1980s I think. I don't know if it is from the same code base as GNU Screen.<p>Being able to attach to a persistent TTY context is indeed a nice feature, and as far as I'm aware, the program didn't have that when I last tried it.<p>One difficult aspect of being a Luminary is that I don't get to hack as much as I'd like to. Too busy doing things like flying to Tunis for WSIS. Sometimes I get to hack on the plane, and of course the network connectivity leaves something to be desired.<p><i>Bruce</i>

tabs in gnome terminal

Posted Nov 1, 2005 23:43 UTC (Tue) by BrucePerens (subscriber, #2510) [Link]

Don't have time to push the HTML button either, I guess :-)

tabs in gnome terminal

Posted Nov 1, 2005 23:57 UTC (Tue) by nix (subscriber, #2304) [Link]

I have used a program called "screen" on various Unix systems, mostly in the late 1980s I think. I don't know if it is from the same code base as GNU Screen.
It probably is GNU screen. screen is an old, old program: the oldest date I can find in the source tree is 8/7/91, and that is for version 3.00.01; I can't find any history of changes preceding 2.0a at all. (2.0a introduced `detach'.)

It's been stable for a long time: it's only fairly recently converted from autoconf *1*.

Actually, scratch that, there are copyright statements which say

* Copyright (c) 1987 Oliver Laumann

so I guess it started in '87. Which makes it about as old as, say, GCC...

tabs in gnome terminal

Posted Nov 2, 2005 4:18 UTC (Wed) by iabervon (subscriber, #722) [Link]

screen is worth your time, then. I've been using it for years by running it on my server over an SSH connection. When it's time to go somewhere else, I detach, go where I'm going, log in, and continue what I was doing. It's pretty much ideal for bursts of connectivity; you can connect, type the next two and a half shell commands, and disconnect when you have to get on the plane or something. It also detaches when you lose the connection, so a flaky connection isn't so big a deal; just reconnect and keep typing.

The documentation is a bit understated, though, so it's easy to not realize that it has some amazing feature you didn't know about if you don't think to look. Like, you can now attach a non-detached session, so if you've got the equivalent of one gnome terminal with four tabs, and you want to see two of those tabs at the same time, you can just attach the session again in another xterm, and you've got both tabs. But you wouldn't know from the documentation that this is available unless you actually looked for it.

tabs in gnome terminal

Posted Nov 2, 2005 6:03 UTC (Wed) by drag (subscriber, #31333) [Link]

Oh.. Sweet mother of mercy, screen is absolute wonderfull item. 100% wonderfull and usefull and I use it every freaking day, I am suprised that people can get along without it!

It's a essential item for when you need to run connections over a internet connection. If your doing a update on a server or compiling a big package on a remote machine you can go ahead and start the command, close out the terminal, walk around, get on a different computer, then ssh back into the machine and watch the progress of the command again.

I don't use it much at all when I am on a local machine since I loose the ability to launch X apps from the command line. (which I tend to do since it's faster then hunting for them in the application menus)

Also I find it handy for IRC chat rooms. If I am at work I can ssh into my home computer start screen and get on a chat room and BS around on there. (don't worry this is perfectly fine behavior at my place of employement). But then I can leave, go home to my desktop, then open up screen there.

It's great. When I administrate a bunch of machines I often will have a server that I'll run screen on that would be like a 'spider' with connections to many other systems.

Now if they could do something similar to this with X then that would be heaven.. not so much the multiplexing of X servers like screen does shells, but more like the persistance. Since X is network transparent for the most part it makes sense that I should be able to open up a application on one computer then pull it over to another computer, or push the display output to something else. It would be handy for lots of reasons. I beleive Sun has something like this for their brand of X terminals (sunfires or something like that?) Were a person can close out a terminal and then pick up the same session on another. Since this sort of thing would be implimented at the X server level then applications won't have to be specificly designed to hook into a managed session thing like the limited functionality that gnome supports and such.

tabs in gnome terminal

Posted Nov 2, 2005 10:00 UTC (Wed) by ibukanov (subscriber, #3942) [Link]

> Now if they could do something similar to this with X then that would be heaven.. not so much the multiplexing of X servers like screen does shells, but more like the persistance.

Did you try VNC, www.realvnc.com or its versions in various Linux distributions?

This is exactly how I work running a develpment environment on a fast computer inside VNC X-server at work and then using VNC clients to connect to it from a quite old laptop over network with SSH. This works nicely over 1MBit broadband line but even with 33KBit dial-up it is still useful.

tabs in gnome terminal

Posted Nov 2, 2005 16:34 UTC (Wed) by iabervon (subscriber, #722) [Link]

I don't use it much at all when I am on a local machine since I loose the ability to launch X apps from the command line. (which I tend to do since it's faster then hunting for them in the application menus)

It doesn't interfere, except that if your display changes when you detach and reattach, you need to set your DISPLAY environment variable in each shell again (which can be a pain if you've got a long-running program).

Now if they could do something similar to this with X then that would be heaven.

One of these days, I bet I'll be reading the screen man page and find that the latest version handles it. That's really the right place to attach the functionality, when you already have the stuff in place for detaching and attaching sessions (including both the user interface and the code for handing things off between processes).

tabs in gnome terminal

Posted Nov 3, 2005 14:49 UTC (Thu) by wookey (subscriber, #5501) [Link]

I used to think tabbed terminals were pretty neat until I discovered (was shown) screen, then I was hooked. It is, as mnay have pointed out - bloody marvellous. My only gripe is that I wish the default binding wasn't ctrl-a as it can be hard to remember whether a particular term is a ctrl-a, or a ctrl-a, a term (for start of line). The number of times I have done 'ctrl-a' 's','u','d','o', and achieved stopping the terminal stream rather than adding sudo to the start of the line is incalculable. (yes, I know I can change it, but there are too many computers for this to be reliable/practical - I just ended up with a mix of escape chars on different boxes, which was worse (and the convenient alternative ctrl-\ interferes with mc in bad ways too) (mc being the next most useful console thing in the world after screen)).

Now - to the point. My understanding is that NX provides the connect/disconnect functionality of screen for X sessions (as well as dramatic speedups over the networks). Personally I have failed to get NXfree server to work, but I expect it to provide screen-for-X in the future, which will be very cool indeed for those unavoidable X-apps you sometimes need, and just having the same desktop at home and work, rather than just the same xterms. Being able to 'screen' my firefox instances would be very handy.

screen command character

Posted Nov 3, 2005 20:19 UTC (Thu) by grumpendorfer (subscriber, #169) [Link]

I use ^] as my screen command character since I don't use telnet anymore. And I've never missed `abort-recursive-edit' either.

Chris Leyon

Screen in an xterm?

Posted Nov 1, 2005 23:14 UTC (Tue) by Quazatron (subscriber, #4368) [Link]

Yes, but screen lets you 'detach' from the current screen, go home, ssh back to work, and 'attach' to the exact same screen you were working on. Trés useful, oui?

Screen in an xterm?

Posted Nov 1, 2005 23:40 UTC (Tue) by stumbles (guest, #8796) [Link]

That's the cool thing about screen. It's detachablility, hee hee.

Screen in an xterm?

Posted Nov 2, 2005 4:44 UTC (Wed) by sanjoy (subscriber, #5026) [Link]

I use screen all the time for detaching and attaching, and the magic command I find most useful is

screen -D -R -A

-D -R means detach a session if needed, then reattach, and -A means to adjust window sizes if needed.

So I have r as an alias for that command, and just type r by reflex whenever I login.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 1:08 UTC (Wed) by nirik (subscriber, #71) [Link]

You are all missing another wonderfull feature of screen:

You can have multiple people attach from diffrent locations at the same time and see what each other are typing. This is very useful for remote training, etc.

You can use a phone call or irc or IM session to talk about whats going on in the screen and walk someone through a task.

Very handy.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 4:52 UTC (Wed) by TwoTimeGrime (guest, #11688) [Link]

> You can have multiple people attach from diffrent locations at the
> same time and see what each other are typing.

How does one do that? I'm looking around the man page but I'm not sure what text to look for.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 5:22 UTC (Wed) by nirik (subscriber, #71) [Link]

For the easiest example:

person a logs in as user 'a'.
person a runs 'screen -a'
person b logs in as user 'a' (ie, they have to be logged in as the same user).
person b runs 'screen -x'

Both person a and person b can see what each other are typing and the output of the commands either runs.

My sysadmin toolbox (Linux.com)

Posted Nov 3, 2005 7:14 UTC (Thu) by jello (subscriber, #6083) [Link]

In recent versions of screen you can also do this with different accounts. The screen binary must be suid, then userA runs screen, does ctrl-a ':multiuser on', then ctrl-a ':acladd userB', then userB can run 'screen -r userA/' to attach. All that can be put in the .screenrc too of course.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 3:01 UTC (Wed) by kmself (subscriber, #11565) [Link]

I know 'em by the first command I run on a new system: aptitude install vim screen ssh w3m lftp gpw mutt mc. I'd probably throw netcat into the list, though there's a number of other tools I find darned useful as well.

And another one: qemu for quickly assessing bootable images, etc.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 11:07 UTC (Wed) by climent (subscriber, #7232) [Link]

Well, what i do is

svn co https://mysvnserver/svn/home/trunk
. ./trunk/.bashrc
1strun (script to switch over from trunk to home)
sudo 1stinstall

(script to install all my utilities, which include
subversion, vim, abcde, screen, mutt, mc, curl, lftp, ...)

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 5:14 UTC (Wed) by beoba (guest, #16942) [Link]

Random recommendation that may come in handy for some people:

If you only use screen for its ability to detach/reattach sessions, you might find "dtach" useful.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 6:15 UTC (Wed) by Arker (guest, #14205) [Link]

It's true that screen is still very useful in an xterm, but I can't believe no one has challenged the implication that no one works in console mode anymore. Console mode is great, particularly on a slower machine, or even a blazingly fast machine hooked up to a smaller monitor, on a server under load where you really don't want to load X on top of everything else, etc. etc. Console mode is still very very useful.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 8:48 UTC (Wed) by khim (guest, #9252) [Link]

It's true that screen is still very useful in an xterm, but I can't believe no one has challenged the implication that no one works in console mode anymore. Console mode is great, particularly on a slower machine, or even a blazingly fast machine hooked up to a smaller monitor, on a server under load where you really don't want to load X on top of everything else, etc. etc.

Do you want to say my Zaurus is blazingly fast and it has huge monitor ? Pure console mode is almost dead - the only reason I spend so much time in xterm's one is inability of screen to handle graphical programs (shame really since rdesktop+MS Windows handle them just fine - so much for "better networkability of linux").

Console mode is still very very useful.

I only see console when I load linux with init=/bin/bb for rescue purposes... Or when X server refuses to start - not exactly great time to start playing with screen...

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 9:35 UTC (Wed) by hppnq (subscriber, #14462) [Link]

Pure console mode is almost dead - the only reason I spend so much time in xterm's one is inability of screen to handle graphical programs (shame really since rdesktop+MS Windows handle them just fine - so much for "better networkability of linux").

Damn, the Enderle fortune(6) database has been released and nobody told me.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 13:22 UTC (Wed) by BrucePerens (subscriber, #2510) [Link]

Pure console mode is almost dead - the only reason I spend so much time in xterm's one is inability of screen to handle graphical programs (shame really since rdesktop+MS Windows handle them just fine - so much for "better networkability of linux").

This is absurd. There are a number of remote desktop programs for Linux, VNC comes to mind. To even think that screen should be compared to rdesktop - you must have no concept of what it does. Sorry to be harsh, but this one merits it.

Bruce

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 13:50 UTC (Wed) by pointwood (guest, #2814) [Link]

From what I head you should really take a good look at NX from nomachine.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 9:36 UTC (Wed) by NightMonkey (subscriber, #23051) [Link]

To all those fellow Screen lovers who want a nice tabbed interface like Gnome Terminal, but using Screen to manage your sessions.... I present you with...

Eterm!

http://www.eterm.org/docs/view.php?doc=man

Look through the man page, and you'll see that you can instatiate a Screen session within an Eterm, and even, with SSH as the underlying connection, connect to _remote_ Screens, with tabs and all. I like it. You might, too.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 9:58 UTC (Wed) by hppnq (subscriber, #14462) [Link]

There are many unsung heroes of Unix/Linux system administration: the likes of lsof, vmstat, netstat, grep, stat and a shell are often taken for granted, but are essential for many typical tasks. While a program such as screen is without a doubt incredibly useful, I have never had to rely on it for administrational stuff, whereas I really couldn't live without the aforementioned.

screen and scrolling

Posted Nov 2, 2005 11:39 UTC (Wed) by niner (subscriber, #26151) [Link]

screen has only one disadvantage: it effectively prevents me from scrolling up my terminal when used via ssh. Neither konsole scrollbar or mousewheel, nor shift+pgup work.

screen and scrolling

Posted Nov 2, 2005 13:13 UTC (Wed) by zooko (subscriber, #2589) [Link]

On the other hand, screen has a scroll back buffer of its own. Hit C-a ESC to enter scroll back
mode, then page-up or C-u or such. There is a rich vi-like interface for navigating and cutting and
pasting.

ah thanks

Posted Nov 2, 2005 13:35 UTC (Wed) by niner (subscriber, #26151) [Link]

Typing C-a [ to access copy mode is really no fun on a german keyboard (you have to type Strg+a Alt Gr+8), but C-a ESC fits into the tolerance.

screen and scrolling

Posted Nov 2, 2005 13:15 UTC (Wed) by lwn163 (guest, #11797) [Link]

You are going to have to find something else! :)

Just go into copy mode (Ctrl-A [), and then you can scroll back
as many lines as defscrollback is set to in your .screenrc. I have mine set to 10000.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 12:09 UTC (Wed) by carcassonne (guest, #31569) [Link]

Syntax highlighting is still considered, in 2005, an editor feature ?

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 12:34 UTC (Wed) by niner (subscriber, #26151) [Link]

Highlighting for nearly every known syntax under the sun, yes.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 17:05 UTC (Wed) by carcassonne (guest, #31569) [Link]

We'll keep'em editor developers busy by continuously adding new syntaxes !

That'll prevent them from programming Tetris games into their editors !

;-)

too little, too late

Posted Nov 2, 2005 21:53 UTC (Wed) by niner (subscriber, #26151) [Link]

Obviously there's not enough syntaxes out there...

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 14:14 UTC (Wed) by dps (subscriber, #5725) [Link]

Risking feeding a troll or 3, I would assert that serious servers have no business running X clients (and *definitely* not X servers, which make no sense on a box without a screen, mouse or keyboard). My editor of choice is emacs, which is OTT for seriously minimised servers.

AFAIK VNC does not need a X server, but should be nowhere within a mile radius anyway as using it requires X clients. Really seriously paranoid boxen, like the firewall, do not have any text editors either---if you want to edit a file then scp, edit, and then scp back.

Note this implies I *must* use console mode to administer the those minimised servers, period (albeit via a s* connection in a xterm). My toolbox would include nmap, ssh, nslookup, telnet, ping and tcpdump wihtin reach of a scp,

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 17:49 UTC (Wed) by captrb (subscriber, #2291) [Link]

Really seriously paranoid boxen, like the firewall, do not have any text editors either---if you want to edit a file then scp, edit, and then scp back.

But REALLY REALLY seriously paranoid boxen should be entirely disconnected from the network and be unplugged from power. Disconnect the drives as well.

This is ridiculous. SCP'ing config files back and forth as a non-priv user presents more opportunity for mistakes like leaving temporary files in public places, accidentally changing permissions, etc... unless you SCP as root(ha).

If somebody managed to get local access to your machine and you run linux, I'm pretty sure that vi binaries for your current flavor of glibc will be easily located. Not to mention that bash by itself could probably be used to manipulate the files and I doubt that your machine would run without bash. I see the value of having fewer packages installed, but proposing a system without a text editor is security through obscurity. It just puts a tiny speed bump in the path of a hacker, not a barricade.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 18:52 UTC (Wed) by captrb (subscriber, #2291) [Link]


p.s. sorry for the trolling, but I strongly disagreed :-)

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 22:14 UTC (Wed) by nix (subscriber, #2304) [Link]

If somebody managed to get local access to your machine and you run linux, I'm pretty sure that vi binaries for your current flavor of glibc will be easily located.
See DigSig to block that. Anyone cracking into my firewall and wanting to run random binaries on it without cracking the kernel has to either break SHA-1, or get my binary-signing private key, which is on a CD which isn't in the drive.

I think cracking the kernel and killing DigSig that way is probably easier given the number of security holes that keep popping up in there.

My sysadmin toolbox (Linux.com)

Posted Nov 3, 2005 3:07 UTC (Thu) by zblaxell (subscriber, #26385) [Link]

My really serious paranoid boxen have editors installed. They wouldn't trust a file that was edited on some other machine.

My slightly less paranoid boxen (and even some not-paranoid-at-all boxen) have:

- Important files are in a version control system (VCS)
- Signatures are in the VCS and on the paranoid box (and must match)
- VCS, signature private keys, and paranoid box are different, mutually distrusting machines.

Changing a file involves:

- Check out file, verify signature
- Edit file, generate new signature, check in
- Package entire contents of VCS and send to paranoid box
- Paranoid box verifies signatures stored locally on paranoid box for old files installed on system
- Paranoid box verifies signatures from VCS of old files installed on system
- Paranoid box verifies signatures of new files to install
- Paranoid box installs new files

Of course, if any of those steps fail, it's back to step 1.

The scripts are designed to do things like notice when a config file doesn't match what's in the VCS before whatever is in the VCS clobbers it If the machine has multiple administrators or is applying distro security patches, the signature checks notice this and send back diffs. It also ensures that the new files are based on exactly the previous version in the VCS--a signature is required both for the new files to be installed and the old files that were previously installed. Replay attacks are prevented, so remote system upgrades and reconfigurations can be sent over email.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 15:57 UTC (Wed) by stijn (subscriber, #570) [Link]

cat <<EOAD;
The list includes cdargs, a program mentioned before both there and here. In the end I decided that the overlap of cdargs functionality and what I needed was too small, so I wrote apparix. Basically both cdargs and apparix allow one to bookmark and jump to directories. cdargs features a prominent curses interface, whereas apparix does not - it assumes you know where you want to jump. It also supports CDPATH style bookmarks.
EOAD

Some of the earlier discussion here ended up in the manual NOTES section.

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 22:18 UTC (Wed) by nix (subscriber, #2304) [Link]

Cool stuff.

Suggestion: write a completion script for bash-completion which uses apparix --quo to determine available completions. The best of all worlds!

My sysadmin toolbox (Linux.com)

Posted Nov 2, 2005 22:43 UTC (Wed) by stijn (subscriber, #570) [Link]

Sitaram just sent me a patch to that extent, which I'm including in the documentation. The listing can be achieved by invoking apparix with no argument or catting its resource files. The patch does the latter with grep and cut thrown in.

Another small but convenient new feature (ETA by tomorrow) is that bm without arguments will simply bookmark the current directory by its trailing component.

Finally, (not so) Clueless Moron on slashdot came up with these:

         mk() { eval ${1:-MKPWD}=\"`pwd`\"; }
         rt() { eval cd \"\$${1:-MKPWD}\";pwd; }

         # type "mk" (as in "mark") and "rt" (as in "return") to mark
         # a directory and later go back to it.
         # Or give it a name: do "mk foo", and later on "rt foo"

where mk and rt where named after troff primitives. It's interesting to see that many people have found ways to implement jumping

My sysadmin toolbox (Linux.com)

Posted Nov 3, 2005 9:48 UTC (Thu) by nix (subscriber, #2304) [Link]

At work I am stuck with ksh, which doesn't have pushd or popd. Solution:
function pushd
 {
  PWDSTACK=${PWD}:${PWDSTACK}
  cd $1
 }

function popd
 {
  cd $(echo ${PWDSTACK:-${PWD}} | cut -d: -f 1)
  PWDSTACK=$(echo ${PWDSTACK} | cut -s -d: -f 2-)
 }

function dirs
 {
  echo $PWDSTACK | tr ":" "\n" | sed '/^$/d'
 }
(warning: this code was written ten years ago when I barely knew shell scripting and not touched since then; it has notable problems, trivially fixed, with directories with names starting with minus signs).

Now I just have to cope with the problem that on some proprietary Unixes evaluating functions longer than about 64 characters in the .envrc causes ksh to dump core...

My sysadmin toolbox (Linux.com)

Posted Nov 3, 2005 15:18 UTC (Thu) by stijn (subscriber, #570) [Link]

more loveliness - I made a note of it to further my documentation of this worthy pursuit :)

Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds