0

I often have tens of gnome-terminals opened when I am working at my CentOS Desktop (Virtual Machine). This can mean I have about 40 open SSH sessions to different servers.

What is the best way to find back the SSH-session for a specific server? I sometimes just pkill bash, pkill ssh, pkill gnome-terminal in order to start over again or just open another gnome-terminal for that server and type ssh hostname.

A simple method to find back an existing gnome-terminal with SSH connection to a server would be better though. The taskbar in GNOME shows the window titles, but after 10 SSH sessions they cannot be read anymore, because they're too close to each other and there isn't enough space to write the hostnames.

I would love to have some experience from other Linux system administrators on this issue.

ujjain
  • 3,983
  • 16
  • 53
  • 91

1 Answers1

2

Get into the habit of using GNU Screen. Install it with yum install screen.

Screen is a "terminal multiplexer". What does that mean? It's like a terminal within a terminal, which you can leave and come back to.

You start a screen session by running screen. You can have multiple terminals within the one session. You create a new terminal using Ctrl+A then Ctrl+C. You switch between terminals using Ctrl+A then a number key. You can also do Ctrl+A then n for next, and Ctrl+A then p for previous.

The magic of screen comes when you have to leave. You "detach" from your screen session with Ctrl+A then d. You log in from somewhere else and re-attach with screen -r and all your terminal windows are sitting within your screen session just how you left them.

There are many user guides out there which cover more usage, just search Google for "gnu screen". You can press Ctrl+A then ? for help within the program.

You'll probably want to create a ~/.screenrc file to permanently store settings, including making a bar at the bottom which lists all your active terminal windows. Here's mine:

termcapinfo * ti@:te@
defscrollback 51200
hardstatus alwayslastline "%{=b}%{kG} %-w%{W}%n*%t%{-}%+w %=$USER@%H | %0c %A %D, %M %d %Y "
screen -t four 4
screen -t three 3
screen -t two 2
screen -t one 1
screen -t zero 0

You could use labels within screen (Ctrl+A then A) to give all your terminals a name. You could then easily see which terminal you're switching to, or you can see an entire list of open terminals with Ctrl+A then ". You can then look up and down with the arrow keys and choose the one you're after.

suprjami
  • 3,536
  • 21
  • 29