fbpx Multiple Terminals Over One SSH Connection with tmux | Certificação Linux

Manage Multiple Remote Terminals Over a Single SSH Connection

📅 10/02/2018 ⏱ 2 min ✍️ Uira Ribeiro
Linux
Manage Multiple Remote Terminals Over a Single SSH Connection
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

Do you know the screen command?

The screen command is a powerful window manager that multiplexes a physical terminal between several processes. It allows the user to open several instances of different terminals on the same physical terminal. You can also share your terminal with other users.

If you needed to open several SSH connections to your Linux to have more than one terminal available, it's because you still don't know screen.

&feature=youtu.be

Once you type screen, it will open a terminal like any other. But it will enable various commands. To see screen's HELP, type Ctrl-A and "?" (without quotes). All screen commands must be preceded by Ctrl-A.

Imagine that you are connected via SSH to a server and you are going to download a large file that will take 2 hours. You can run the download "inside" screen, disconnect from the terminal, and then reconnect later, even from another computer.

$ screen

$ wget http://servidornaweb.com.br/arquivomuitogrande.tar.gz

You can type Ctrl-A and the "d" key to disconnect from the terminal. Now you can even disconnect from the SSH session.

When you want to reconnect to the screen terminal, reconnect to the SSH session, and then type the command:

$ screen –r

If you have more than one session open in screen, you must specify which session you want to connect to. To see which sessions are open:

$ screen -ls

There is a screen on:

        12604.pts-0.svnserver   (Attached)

1 Socket in /var/run/screen/S-ec2-user.

 

To connect to session 12604:

$ screen –r 12604

You can also open several sessions with Ctrl-A, then "c". To switch between sessions, you must type Ctrl-A and then "n" or "p" to navigate forward (Next) or backward (Previous). This saves you from having to connect multiple times via SSH.

You can also enable logging of everything typed in the terminal by activating the log through the Ctrl-A and "H" command. To disable the log, just press Ctrl-A and "H" again.

Learn much more about Linux in our online course. You can enroll here with a 7-day free trial. If you already have an account, you can access it here.

Did you like it? Share :-)

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp