PDA

View Full Version : Sysadmin - make your tasks easier.


david
04-03-2006, 03:52 AM
Just to start a thread with tips for sysadmin tasks:

I highly recommend using a terminal multiplexer like "screen"

With screen you can run multiple shell sessions in the same window. So, if you are at work/home, instead of having many xterm/konsole/putty windows open and all connected to your server, you could just have one window with screen running and switch back and forth "screen windows"

Another plus for screen is that you could leave your session running and detach your current window from it, so your screen shells continue running in the background. This is good when you are leaving work and/or would like to go to another computer later on and re-attach yourself to your previous terminal. I use this to leave gentoo's emerge doing it's job overnight and next day I come back to see results, like if I hadn't ever signed off, which helps in those cases when your local link goes down (if you are not running screen and you are running a process on the foreground, if you loose your connection the process will die)

Quick screen steps:

1. Install screen ( in gentoo, emerge -Du screen)
2. In your terminal, type: screen
3. You'll see a new prompt, nothing different really, but now you could open more "screen windows" in the same terminal window. Hit "Ctrl-a-c" (Ctrl-A is the prefix for screen commands, it can be changed to another letter if you like).

4. You'll see another prompt, now you can navigate back and forth windows like this: Ctrl-a-" (ctrl-a double quotes), you'll see a window menu which you can navigate with the arrow keys and press enter in your selection.

5. Rename each window with a meaningful title. Press Ctrl-a-A (ctrl-a capital A) to rename the current window's title. Now you can run different commands on each window (say for example, in window 1 you run $tail -f /var/log/messages , and in window 2 you are doing a manual telnet test for checking your e-mail server). You can open window 3 and do your system upgrad (emerge -Du world or yum update , etc)

6. Now say you want to leave the computer but not leave the window open for anybody else to mess with it. So you need to detach yourself with Ctrl-a-d

7. When you come back and want to get back into your screen session. Type " screen -r -d" (reattach screen session and detach all other attached sessions, like if you forgot to detach your session at work earlier, you can detach it remotely from home).

I find this program to be very useful and I use it everyday (have pine running on one window, irrsi on another one, etc).

There are plenty of tutorials about screen, hope this one illustrates a little bit better.

http://www.linuxplanet.com/linuxplanet/tutorials/6206/1/


My 2 cents.

David

stonedge
04-04-2006, 02:44 AM
That could come in very handy.
Have you tried running a remote X app on the server from home through screen?

david
04-04-2006, 03:05 AM
Screen works OK with X apps as far as I know. I generally don't launch remote X apps, but I also use screen on my local system and from there I launch X apps. I have noticed couple of times that the DISPLAY system is not set or set incorrectly after a long time I've had a screen session open (weeks/months). I just reset the DISPLAY variable ( export DISPLAY=:0 ) in my local system and it all works again.