JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM >

Screen Command in Linux

Author:JIYIK Last Updated:2025/04/06 Views:

This article explains how to create, attach, detach, record and exit a screen session in Linux using screencommand.

screenWhat is command in Linux?

screenThe 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.

screenThe command helps to separate processes running on your terminal by placing them in different sessions. screenThe command allows you to switch between sessions and select the session to attach to.

screenLaunch screen in Linux using command

Launch the program in Linux screen. Type as shown below screenand press Enter.

Screen Image 1

The above command displays the following output. Press <Enter> and Spaceyou will be directed to the terminal.

screenimg2

From the terminal, you can run commands just like you would in a normal terminal environment.

We are now screenin 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.

screenimg3

screenList all screen sessions in Linux using command

To list all the screens available on our machine, we use the command with the -lsor -listoption screen.

The image below shows the available screens on our machine.

screenimg4

screenAttach screen session in Linux using command

We use the command with -rthe detach option screenwhich takes a session ID as an argument in order to return to the screen session after detaching.

We have reattached 2276the session with ID in the following figure.

screenimg5

screenStart screen logging in Linux using command

To enable logging when we start a screen session, we use the command with -Lthe -log option . It will create a log file for the screen session in the screencurrent -log folder.screenlog.0

We start a new screen session and enable logging in the image below.

Screen img6

Once inside the screen session we type the following command and then detach the session by typing Ctrl+ Aand D.

Screen img7

Now that we are outside of the session, we use lsthe command to list the contents of the current directory and pipe the output to grepthe command. grepThe command looks for screenlogmatches and displays the lines that match.

The image below shows that we have a screenlog.0screen log file called .

screenimg8

To leave the screen terminal session, you can press Ctrl+ Aand Dto detach the screen. You can also type the command on the terminal exitand 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.

Article URL:

Related Articles

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

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial