2 Tools for Linux Terminal Sharing

0
296
2 Tools for Linux Terminal Sharing

Dit bericht verscheen eerder bij FOSSlife

At times, you wish you could explain what you are seeing on the screen of your Linux system to someone else. Although you could exchange screenshots, being able to interact would be so much better; thus, the basis for Linux terminal sharing.

Several tools let you share a screen, including tmate, tmux, screen, teleconsole, tty-share, ttyd, named pipe/FIFO, WebTTY, and byobu, to name a few.

In this article, I cover what are generally considered the most common tools: screen and tmux.

screen

The screen application is a terminal multiplexer that allows you to connect and disconnect from sessions. You simply type screen to get started. Although you won’t really see any difference in the terminal, you have started screen. To show you what it can do, start a download:

$ wget https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.6-x86_64-dvd1.iso

Once the download starts, disconnect (detach) from the session while leaving the download to continue by typing Ctrl+A-d (i.e., press and release Ctrl+A and then press d). In the terminal, you should see something like:

$ ls -s
total 621176
     4 Desktop     4 Downloads  4 Pictures  621144 Rocky-8.6-x86_64-dvd1.iso  4 Videos
     4 Documents   4 Music      4 Public         4 Templates

Notice that you see the ISO file downloading, and if you check the size, you will see that it continues to increase.

Note that the wget terminal command runs headless in the background, which is the important feature of terminal sharing. Even if you close the terminal, the session will still be running, allowing you to open another terminal and reattach to the screen session in that new terminal.

As you will see in a subsequent section, you can even SSH from a remote system into the system in which you started the screen session and attach to it.

To reconnect (reattach) to the screen session, just type:

$ screen -r

You should see the terminal window much as you did before:

$ wget https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.6-x86_64-dvd1.iso
--2022-07-06 12:48:08--  https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.6-x86_64-dvd1.iso
Resolving download.rockylinux.org (download.rockylinux.org)... 146.75.82.132, 2a04:4e42:83::644
Connecting to download.rockylinux.org (download.rockylinux.org)|146.75.82.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11213471744 (10G) [application/octet-stream]
Saving to: Rocky-8.6-x86_64-dvd1.iso
 
Rocky-8.6-x86_64-dvd1.iso     35%[===========>                         ]   3.74G  37.4MB/s    eta 2m 45s

When you reconnected to the session, you didn’t specify a particular one. Because you can have more than one screen session running at the same time, you sometimes have to specify a particular session. To get a list, use the command:

$ screen -ls

There is a screen on:
  8520.pts-0.laytonjb-desktop (07/06/2022 12:45:36 PM) (Detached)
1 Socket in /run/screen/S-user1.

The output from the command lists the sessions that are available. You can reconnect to a session with:

$ screen -r 8520.pts-0.laytonjb-desktop

You’ll be reconnected to the session and should see the download continue.

Sharing a Screen Session

If two users are logged in to a single system on the same account, they can share a screen session between them. Whatever one user types, the other user sees.

For example, on a remote system, laytonjb-desktop, user1 creates a session:

$ screen -d -m -S remote

This command starts a detached session named remote; user1 can attach to the session with the command:

$ screen -x remote

Next, user1 on another system, named APEXX, uses ssh to log in to laytonjb-desktop. After logging in, it joins the session with the command:

$ screen -x remote

Everything that appears on your terminal will also appear on the terminal of the user on the other system. For example, user1 logs in to laytonjb-desktop with

$ help me from laytonjb-desktop

as shown in Figure 1; Figure 2 shows the APEXX machine.

Dit bericht verscheen eerder bij FOSSlife

Vorig artikelelectron
Volgend artikelOutreachy December 2022 Internships Now Open