Screen Command in Linux
This article explains how to create, attach, detach, record and exit a screen session in Linux using screen
command.
screen
What is command
in Linux?
screen
The screen command is a bash program used to manage Linux windows. Using the screen command, you can start multiple screen sessions. A screen session can also have multiple windows.
screen
The command helps to separate processes running on your terminal by placing them in different sessions. screen
The command allows you to switch between sessions and select the session to attach to.
screen
Launch screen
in Linux using command
Launch the program in Linux screen
. Type as shown below screen
and press Enter.
The above command displays the following output. Press <Enter> and Spaceyou will be directed to the terminal.
From the terminal, you can run commands just like you would in a normal terminal environment.
We are now screen
in the terminal session that we started with the command. To detach from the session, press Ctrl+ Aand D.
You will see output similar to the following.
screen
List all screen sessions in Linux
using command
To list all the screens available on our machine, we use the command with the -ls
or -list
option screen
.
The image below shows the available screens on our machine.
screen
Attach screen session
in Linux using command
We use the command with -r
the detach option screen
which takes a session ID as an argument in order to return to the screen session after detaching.
We have reattached 2276
the session with ID in the following figure.
screen
Start screen logging
in Linux using command
To enable logging when we start a screen session, we use the command with -L
the -log option . It will create a log file for the screen session in the screen
current -log folder.screenlog.0
We start a new screen session and enable logging in the image below.
Once inside the screen session we type the following command and then detach the session by typing Ctrl+ Aand D.
Now that we are outside of the session, we use ls
the command to list the contents of the current directory and pipe the output to grep
the command. grep
The command looks for screenlog
matches and displays the lines that match.
The image below shows that we have a screenlog.0
screen log file called .
To leave the screen terminal session, you can press Ctrl+ Aand Dto detach the screen. You can also type the command on the terminal exit
and it will detach the screen.
Using Ctrl+ Aand Kwill kill the screen.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Linux Sed Tutorial: 6 Examples of Sed Branching Operations
Publish Date:2025/04/06 Views:165 Category:OPERATING SYSTEM
-
Like any other programming language, sed also provides special branching commands to control the flow of the program. In this article, let's review the following two types of Sed branches. Sed unconditional branch Sed conditional branching
awk tutorial – 7 awk printing examples
Publish Date:2025/04/06 Views:118 Category:OPERATING SYSTEM
-
This is the first article in the new awk tutorial series. We will publish several articles on awk in the coming time, which will explain all the features of awk with practical examples. In this article, let's review the basic awk working me
Sed Tutorial: Advanced Sed Substitution Examples
Publish Date:2025/04/06 Views:80 Category:OPERATING SYSTEM
-
In this article, let's review some interesting workarounds using the "s" substitution command in sed with a few real-world examples. 1. sed replaces the delimiter As we discussed in our previous article, we can use different delimiters in s
Installing Python modules without root access
Publish Date:2025/04/06 Views:67 Category:OPERATING SYSTEM
-
Use --user the -p option to install Python modules without root access, for example pip install requests --user . --user The -p option installs the package in the user's home directory and helps resolve permission issues. $ pip install requ
How to run TypeScript files from the command line
Publish Date:2025/04/06 Views:54 Category:OPERATING SYSTEM
-
Run TypeScript files from the command line using the ts-node package, for example npx ts-node myDirectory/myFile.ts . ts-node The command will convert the TypeScript file to JavaScript and run the code in one step. This is the TypeScript fi
PBKDF2+HMAC Hash Conflict
Publish Date:2025/04/06 Views:55 Category:OPERATING SYSTEM
-
Cryptocurrency enthusiast Christian 'CodesInChaos' Winnerlein once wrote: plnlrtfpijpuhqylxbgqiiyipieyxvfsavzgxbbcfusqkozwpngsyejqlmjsytrmd and eBkXQTfuBqp'cTcarg* have the same PBKDF2-HMAC-SHA1 hash. This intrigued me, so I decided to find
How to create simple Mac applications from shell scripts
Publish Date:2025/04/06 Views:200 Category:OPERATING SYSTEM
-
Basically, a Mac application has a .app ./file extension, but it's not really a file - it's a package. We can view the contents of an application by navigating to it in the Finder, right-clicking it, and then selecting " Show Package Conten
How to Find IP Address from Host Name in Windows Linux and Unix
Publish Date:2025/04/06 Views:89 Category:OPERATING SYSTEM
-
How many times in a day do we have a hostname and want to know the IP address? While dealing with network commands in Unix, hostname to IP address and IP address to hostname conversion is one of the common things we need to do for many thin
How to create, update and delete soft links in Linux and UNIX
Publish Date:2025/04/06 Views:173 Category:OPERATING SYSTEM
-
Symbolic links or soft links in Unix is a very important concept to understand and use in various UNIX operating systems like Linux, Solaris or IBM AIX. Symbolic links provide us so much power and flexibility and make it very easy for