linux multiple terminal session
If you’re a Linux user, you’re going to have to get commenced with the Linux terminal at some point. Some terminal instructions may be popular, others obscure, however in many cases, it’s less difficult to run a command via a terminal window than via a GUI.
But what takes place if you want to run numerous commands at once? GNU Screen makes terminal multitasking like this easy; let’s get you commenced the usage of it.
|
linux multiple terminal session |
What Is GNU Screen?
- GNU Screen is a device for the Linux terminal that splits one terminal into several. It means you can run one command, say a wget download of an picture file, whilst switching to run a second, such as systemctl, to check the S.M.A.R.T. popularity of your drive.
- It permits you to run unbiased instructions like these in separate sessions that you can connect and disconnect to at will.
- It’s now not simply useful for your very own PC; it’s nearly integral if you’re managing a faraway server. If you’re going for walks commands on a server over SSH, what takes place if you disconnect? The command would possibly nevertheless be running, but you won’t be in a position to effortlessly monitor or engage with it.
- Screen deals with that trouble for you. You can reconnect to a Screen session if you lose connection, or detach from it and depart it going for walks in the history till you need to get entry to it again.
How to Install Screen
|
Screen Terminal Apt Install |
- Screen doesn’t come with most Linux distributions, however as it predates Linux, it’s properly supported.
- If you prefer to deploy it on an Ubuntu or Debian-based distro, run the following:
Linux Station with Screen
- sudo apt-get update
- sudo apt-get install screen
- Similarly, if you’re walking Arch, open up your shell window and run:
- sudo pacman -Syu
- sudo pacman -S screen
- If you’re using Fedora, run this instead:
Multitask on Linux Station with Screen
- sudo yum update
- sudo yum installation screen
- Starting a Screen Session
- Starting a Screen session is simple. Open up a terminal, or set up an SSH connection, and type screen. You’ll see the Screen introduction window; hit space or your enter key to shut it.
|
GNU Screen Terminal Intro |
- Once you do, your terminal display screen will return to normal. There’ll be no apparent sign that you’re jogging a Screen session, however every command you run from this factor will run inside a session that you can now detach and reattach to at will.
Viewing and Detaching Screens
- You’ll want to recognize how to connect and disconnect from a Screen session if you design on the usage of it again. If you’re already in a Screen session, hit Ctrl + A accompanied by the letter d (lower case).
Screen Terminal Intro
- The session and any commands currently jogging inside of it will detach to run in the background, geared up for reconnection later. Assuming you only have one walking Screen session, type:
- screen -r
- This will reattach your session and enable you to continue. If you need to forcefully detach a session remotely, then reconnect to it yourself, type:
- screen -rd
- You can run greater than one Screen session. If you prefer to reconnect to a particular session, you’ll want to find out the session process ID number. Type display screen -ls or screen -r to list them.
|
GNU Screen Terminal Reattach |
- As the picture above shows, kind screen -r accompanied via the initial ID variety at the start of each session. For example:
Screen Terminal Reattach
- screen -r 25407
- If you choose to shut a session and cancel any strolling instructions within it, reconnect to it and type exit.
Other Screen Terminal Commands to Remember
- Screen has a few hints up its sleeve for customers who want to get the most out of it. Here are a few of the most common terminal commands for you to remember.
List Screen Keyboard Shortcuts
- Like all excellent terminal programs, Screen has keyboard shortcuts for you to use. You’re already using one, Ctrl + A and d, to detach present screens.
- If you favor to see the rest, certainly type Ctrl + A followed by means of ? to give you a list you can work with.
Create and Switch Between Windows in a Session
- You don’t want to switch between classes to run commands; you can additionally switch between windows in one session.
|
Screen Terminal Windows List |
GNU Screen Terminal Window List
- To create a new window in your session, hit Ctrl + A observed by c (lower case) to create a new window. Your first window starts offevolved at range 0, your subsequent window 1, etc.
- Hit Ctrl + A and then filter through the numbers 0-9. To list every one, use Ctrl + A and then w (lower case) to see a listing of periods with a one digit ID.
Create a Session With a Name
- A randomly generated ID is tough to remember; giving your session a title would possibly make things easier. If you choose to begin a session with a name, type:
lock screen session
- screen -S examplename
- If you prefer to reconnect to this session through name, type:
- screen -X examplename
Share a Screen Session
- Want to share a terminal session with a colleague or a friend? Thanks to Screen, you can. Type:
screen -rx
- Rather than detaching anybody presently related to this session, you really be part of it. Other users will see what you kind and the instructions you run; you’ll additionally be capable to watch other customers if they do the same.
Log Your Screen Output to a File
- You may need to log your display output to a file for renovation or auditing reasons. To do so, type:
linux terminal screen split
screen -L
- A session will start with the capacity to log to a file with the title screenlog.x (where X is a number, starting from zero) in your home directory. To start a log in a session, kind Ctrl + A followed with the aid of H (Shift + h).
Lock a Screen Session
- If you favor to guard a screen session, you can lock the session with your present Linux password.
- Type Ctrl + A followed by using x (lower case) to lock a session while you’re currently connected to it.
Screen Terminal Locked Window
|
Screen Terminal Lock |
This locks it in your modern-day terminal window; kind in your account password to unlock.
Terminal Multitasking Couldn’t Be Simpler
- Thanks to GNU Screen, you don’t have to worry about ready for a terminal command to finish. It’s useful if you’re looking to manage far off servers, however it’s additionally a top notch tool for your domestic PC if you want to run quite a few commands from one window.
linux multiple terminal session
- It’s the best device for system admins. It’s no longer the solely command for your Linux terminal toolbox, however, which is why you have to bookmark this cheat sheet of essential Linux commands.
0 Comments