🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 103 (from laksa081)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
1 day ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.geeksforgeeks.org/linux-unix/screen-command-in-linux-with-examples/
Last Crawled2026-04-05 11:54:39 (1 day ago)
First Indexed2025-06-15 14:00:16 (9 months ago)
HTTP Status Code200
Meta Titlescreen command in Linux with Examples - GeeksforGeeks
Meta DescriptionYour All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more., Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Meta Canonicalnull
Boilerpipe Text
Last Updated : 11 Jul, 2025 The screen command is an advanced terminal multiplexer that allows you to have multiple sessions within one terminal window. It's like having "tabs" in your Linux terminal — you can open, detach, switch, or resume sessions at any time without losing what you're working on. It's particularly convenient for system administrators, developers, or anyone working remotely. From executing lengthy installations to multi-tasking across multiple terminal windows, the screen command is easy to use, lightweight, and already present in most Linux installations such as Ubuntu, CentOS, or Debian. What is Screen Command The screen command for Linux is the remote control of your terminal. It lets you create, deal with, and reattach many terminal sessions in one window. If you ever lost work when your SSH connection dropped or internet went down, screen is your lifesaver tool. Imagine this — instead of having tens of open terminals and risking losing them on disconnect or power outage, you can begin a screen session and continue working at your leisure without having to begin from scratch. It is particularly valuable for system administrators, programmers, or anyone else dealing with Linux remotely. Key Features of the Linux Screen Command Persistence of sessions : Prevent programs from exiting even when logged out. Multi-tasking assistance : Have multiple terminal sessions open simultaneously. Terminal splitting : Look at logs in a window, code in another. Ease of navigation : Switch between screens with keyboard shortcuts. Lightweight & pre-installed : It comes with most Linux distros by default. What is the Screen Command Used For The screen command in Linux can be used for: Running terminal sessions in the background : It is ideal for scripts that are long-running, updates, downloads, or server configurations that will take hours. Keeping programs running after you log out : Despite your internet losing connection or terminating your terminal, the session silently runs in the background. Quickly switch between several terminal windows : It's similar to having several browser windows, but for your Linux command line. You don't need to leave the terminal to switch between tasks. Reattach to previous sessions without losing work : Whether you're on a different device or you just rebooted your computer, you can reconnect to your old terminal right where you left it. Split your terminal window : You can see system logs in one pane and edit files in another, all within the same screen session Syntax: screen [-opts] [cmd [args]] How to Install the Screen Command Most Linux distros ( Ubuntu , Debian, CentOS ) include  screen sudo apt install screen # For Debian/Ubuntu sudo yum install screen # For CentOS/RHEL  How to Use Them 1. Start a New Screen Session To start a new terminal screen session: screen 2. Name Your Session Naming a session helps you keep track of multiple sessions. screen -S file -S: It will start a new window within the screen and also gives a name to the window. It creates a session which is identified by that name. The name can be used to reattach screen at a later stage. 3. List All Running or Detached Screen Sessions To see which screen sessions are active or have been detached: screen -ls -ls: It is used to display the currently opened screens including those running in the background. It will list all the attached as well as detached screen sessions. 4. Detach from a Screen Without Closing It You can safely leave a screen session running in the background by detaching it. screen -d 1643 -d: It is used to detach a screen session so that it can be reattached in future. It can also be done with the help of shortcut key Ctrl-a + d. Here 1643 is the screen id we want to detach. 5. Reattach to a Screen Session To resume work on a previously detached session: screen -r 1643 -r: It is used to reattach a screen session which was detached in past. Note: To check for the manual page of screen command, use the following command: man screen To check the help page of screen command, use the following command: screen --help Commonly Used screen Command Options in Linux To use screen effectively, it's important to understand its command-line options. Option Description -a Forces all capabilities into each window's terminal capability (termcap). `-A -[r R]` -c file Uses a custom configuration file instead of the default  .screenrc . -d (-r) Detaches a running screen session from elsewhere and reattaches it here. -dmS name Starts screen in  detached  mode with a session name (like a background task). -D (-r) Detaches and logs out a remote session and reattaches it here. -D -RR Does whatever is needed to connect to a screen session. -e xy Changes the default control command characters. -f Enables flow control. Use  -fn  to disable, or  -fa  for auto mode. -h lines Sets the scrollback buffer size (number of history lines). -i Interrupts output sooner when flow control is on. -l Turns on login mode (updates  /var/run/utmp ). Use  -ln  to disable. -ls [match] Lists all current screen sessions, with optional name match. -L Enables output logging to a file. -m Ignores the  $STY  variable; forces a new session to start. -O Chooses optimized output over exact VT100 emulation. -p window Pre-selects the named window when screen starts. -q Starts screen quietly. Returns error code if it fails. -Q Sends command output to the stdout of the calling process. -r [session] Reattaches to a detached session (if it exists). -R Reattaches to an existing session or starts a new one. -S sockname Sets a custom session socket name (helpful for managing multiple sessions). -t title Sets a window title (name of the terminal window). -T term Uses a specific terminal type instead of the default  screen . -U Enables UTF-8 encoding support inside the session. -v Prints screen version and build date. -x Attaches to a session even if it's already attached (multi-display mode). -X Executes a screen command in a specific session from outside. Screen Command Shortcuts in Linux (Cheat Sheet) When working inside a screen session in Linux, you can navigate between windows, rename them, detach sessions, and more — all using quick keyboard shortcuts Shortcut Action (What It Does) Ctrl-a + c Create a new window inside the screen session. Ctrl-a + w List all open windows within the current screen session. Ctrl-a + A Rename the current window. Helpful when using multiple windows (visible in  Ctrl-a + w ). Ctrl-a + n Go to the next window. Ctrl-a + p Go to the previous window. Ctrl-a + Ctrl-a Switch back to the last used window. Ctrl-a + k Close (kill) the current window. Ctrl-a + S Split the window horizontally. Switch with  Ctrl-a + Tab . `Ctrl-a + ` Ctrl-a + X Close the active split window. Ctrl-a + Q Close all split windows. Ctrl-a + d Detach the session (keeps it running in background). Ctrl-a + r Reattach a previously detached session. Ctrl-a + [ Enter copy mode (use arrow keys to scroll and select). Ctrl-a + ] Paste copied text inside the screen session. Conclusion Linux's screen command is not just a tool — it's a multitasking lifesaver and remote session manager. If you're writing files, running background jobs, or watching system logs, screen keeps your work from being disrupted, even if your SSH connection is interrupted. By mastering screen, you take command of the way you work with the command line. You can detach sessions, pick up where you left off from another computer, or even split the terminal screen and work smarter. With its built-in shortcuts, session persistence, and lightweight footprint, it's no wonder screen remains a favorite among Linux power users. How to resume screen in Linux? To resume a detached screen session, use the screen -r command followed by the session ID if there are multiple sessions: screen -r If there are multiple sessions, list them first: screen -ls Then resume the desired session: screen -r session_id
Markdown
[![geeksforgeeks](https://media.geeksforgeeks.org/gfg-gg-logo.svg)](https://www.geeksforgeeks.org/) ![search icon](https://media.geeksforgeeks.org/auth-dashboard-uploads/Property=Light---Default.svg) - Sign In - [Courses]() - [Tutorials]() - [Interview Prep]() - [Linux-Unix](https://www.geeksforgeeks.org/linux-unix/linux-tutorial/) - [Interview Questions](https://www.geeksforgeeks.org/linux-unix/linux-interview-questions/) - [Shell Scripting](https://www.geeksforgeeks.org/linux-unix/introduction-linux-shell-shell-scripting/) - [Kali](https://www.geeksforgeeks.org/linux-unix/introduction-to-kali-linux/) - [Ubuntu](https://www.geeksforgeeks.org/linux-unix/how-to-install-ubuntu-on-virtualbox/) - [Red Hat](https://www.geeksforgeeks.org/tag/red-hat/) - [CentOS](https://www.geeksforgeeks.org/linux-unix/getting-started-with-centos/) - [Docker](https://www.geeksforgeeks.org/devops/introduction-to-docker/) - [Kubernetes](https://www.geeksforgeeks.org/devops/introduction-to-kubernetes-k8s/) - [Python](https://www.geeksforgeeks.org/python/python-programming-language-tutorial/) # screen command in Linux with Examples Last Updated : 11 Jul, 2025 The screen command is an advanced terminal multiplexer that allows you to have multiple sessions within one terminal window. It's like having "tabs" in your [Linux terminal](https://www.geeksforgeeks.org/linux-unix/linux-online-terminal/) — you can open, detach, switch, or resume sessions at any time without losing what you're working on. It's particularly convenient for system administrators, developers, or anyone working remotely. From executing lengthy installations to multi-tasking across multiple terminal windows, the screen command is easy to use, lightweight, and already present in most Linux installations such as Ubuntu, CentOS, or Debian. ## ****What is Screen Command**** The screen command for [Linux](https://www.geeksforgeeks.org/linux-unix/introduction-to-linux-operating-system/) is the remote control of your terminal. It lets you create, deal with, and reattach many terminal sessions in one window. If you ever lost work when your SSH connection dropped or internet went down, screen is your lifesaver tool. Imagine this — instead of having tens of open terminals and risking losing them on disconnect or power outage, you can begin a screen session and continue working at your leisure without having to begin from scratch. It is particularly valuable for system administrators, programmers, or anyone else dealing with Linux remotely. ### ****Key Features of the Linux Screen Command**** - ****Persistence of sessions****: Prevent programs from exiting even when logged out. - ****Multi-tasking assistance****: Have multiple terminal sessions open simultaneously. - ****Terminal splitting****: Look at logs in a window, code in another. - ****Ease of navigation****: Switch between screens with keyboard shortcuts. - ****Lightweight & pre-installed****: It comes with most Linux distros by default. ## What is the Screen Command Used For The screen command in Linux can be used for: - ****Running terminal sessions in the background****: It is ideal for scripts that are long-running, updates, downloads, or server configurations that will take hours. - ****Keeping programs running after you log out****: Despite your internet losing connection or terminating your terminal, the session silently runs in the background. - ****Quickly switch between several terminal windows****: It's similar to having several browser windows, but for your Linux command line. You don't need to leave the terminal to switch between tasks. - ****Reattach to previous sessions without losing work****: Whether you're on a different device or you just rebooted your computer, you can reconnect to your old terminal right where you left it. - ****Split your terminal window****: You can see system logs in one pane and edit files in another, all within the same screen session ****Syntax:**** ``` screen [-opts] [cmd [args]] ``` ## ****How to Install the Screen Command**** Most [Linux distros](https://www.geeksforgeeks.org/linux-unix/what-are-linux-distributions/) ([Ubuntu](https://www.geeksforgeeks.org/linux-unix/what-is-ubuntu/), Debian, [CentOS](https://www.geeksforgeeks.org/linux-unix/getting-started-with-centos/)) include `screen` ``` sudo apt install screen # For Debian/Ubuntu sudo yum install screen # For CentOS/RHEL ``` ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420104739/Screenshot-675.png) ## ****How to Use Them**** ### 1\. Start a New Screen Session To start a new terminal screen session: ``` screen ``` ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420112254/Screenshot-682.png) ### 2\. Name Your Session Naming a session helps you keep track of multiple sessions. ``` screen -S file ``` - ****\-S:**** It will start a new window within the screen and also gives a name to the window. It creates a session which is identified by that name. The name can be used to reattach screen at a later stage. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420232148/Screenshot-733.png) ### 3\. List All Running or Detached Screen Sessions To see which screen sessions are active or have been detached: ``` screen -ls ``` - ****\-ls:**** It is used to display the currently opened screens including those running in the background. It will list all the attached as well as detached screen sessions. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420231629/Screenshot-723.png) ### ****4\. Detach from a Screen Without Closing It**** You can safely leave a screen session running in the background by detaching it. ``` screen -d 1643 ``` - ****\-d:**** It is used to detach a screen session so that it can be reattached in future. It can also be done with the help of shortcut key **Ctrl-a + d.** Here **1643** is the screen id we want to detach. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420233218/Screenshot-743.png) ### 5\. Reattach to a Screen Session To resume work on a previously detached session: ``` screen -r 1643 ``` - ****\-r:**** It is used to reattach a screen session which was detached in past. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420234423/Screenshot-752.png) ### ****Note:**** - To check for the manual page of screen command, use the following command: ``` man screen ``` - To check the help page of screen command, use the following command: ``` screen --help ``` ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420235222/Screenshot-776.png) ## Commonly Used `screen` Command Options in Linux To use `screen` effectively, it's important to understand its command-line options. | ****Option**** | ****Description**** | |---|---| | **`-a`** | Forces all capabilities into each window's terminal capability (termcap). | | ****\`-A -\[r**** | R\]\` | | **`-c file`** | Uses a custom configuration file instead of the default `.screenrc`. | | **`-d (-r)`** | Detaches a running screen session from elsewhere and reattaches it here. | | **`-dmS name`** | Starts screen in ****detached**** mode with a session name (like a background task). | | **`-D (-r)`** | Detaches and logs out a remote session and reattaches it here. | | **`-D -RR`** | Does whatever is needed to connect to a screen session. | | **`-e xy`** | Changes the default control command characters. | | **`-f`** | Enables flow control. Use `-fn` to disable, or `-fa` for auto mode. | | **`-h lines`** | Sets the scrollback buffer size (number of history lines). | | **`-i`** | Interrupts output sooner when flow control is on. | | **`-l`** | Turns on login mode (updates `/var/run/utmp`). Use `-ln` to disable. | | **`-ls [match]`** | Lists all current screen sessions, with optional name match. | | **`-L`** | Enables output logging to a file. | | **`-m`** | Ignores the `$STY` variable; forces a new session to start. | | **`-O`** | Chooses optimized output over exact VT100 emulation. | | **`-p window`** | Pre-selects the named window when screen starts. | | **`-q`** | Starts screen quietly. Returns error code if it fails. | | **`-Q`** | Sends command output to the stdout of the calling process. | | **`-r [session]`** | Reattaches to a detached session (if it exists). | | **`-R`** | Reattaches to an existing session or starts a new one. | | **`-S sockname`** | Sets a custom session socket name (helpful for managing multiple sessions). | | **`-t title`** | Sets a window title (name of the terminal window). | | **`-T term`** | Uses a specific terminal type instead of the default `screen`. | | **`-U`** | Enables UTF-8 encoding support inside the session. | | **`-v`** | Prints screen version and build date. | | **`-x`** | Attaches to a session even if it's already attached (multi-display mode). | | **`-X`** | Executes a screen command in a specific session from outside. | ## Screen Command Shortcuts in Linux (Cheat Sheet) When working inside a `screen` session in Linux, you can navigate between windows, rename them, detach sessions, and more — all using quick keyboard shortcuts | Shortcut | Action (What It Does) | |---|---| | **`Ctrl-a + c`** | Create a new window inside the screen session. | | **`Ctrl-a + w`** | List all open windows within the current screen session. | | **`Ctrl-a + A`** | Rename the current window. Helpful when using multiple windows (visible in `Ctrl-a + w`). | | **`Ctrl-a + n`** | Go to the next window. | | **`Ctrl-a + p`** | Go to the previous window. | | **`Ctrl-a + Ctrl-a`** | Switch back to the last used window. | | **`Ctrl-a + k`** | Close (kill) the current window. | | **`Ctrl-a + S`** | Split the window horizontally. Switch with `Ctrl-a + Tab`. | | ****\`Ctrl-a +**** | ****\`**** | | **`Ctrl-a + X`** | Close the active split window. | | **`Ctrl-a + Q`** | Close all split windows. | | **`Ctrl-a + d`** | Detach the session (keeps it running in background). | | **`Ctrl-a + r`** | Reattach a previously detached session. | | **`Ctrl-a + [`** | Enter copy mode (use arrow keys to scroll and select). | | **`Ctrl-a + ]`** | Paste copied text inside the screen session. | ## Conclusion Linux's screen command is not just a tool — it's a multitasking lifesaver and remote session manager. If you're writing files, running background jobs, or watching system logs, screen keeps your work from being disrupted, even if your SSH connection is interrupted. By mastering screen, you take command of the way you work with the command line. You can detach sessions, pick up where you left off from another computer, or even split the terminal screen and work smarter. With its built-in shortcuts, session persistence, and lightweight footprint, it's no wonder screen remains a favorite among Linux power users. #### How to resume screen in Linux? > To resume a detached screen session, use the `screen -r` command followed by the session ID if there are multiple sessions: > ``` > screen -r > ``` > If there are multiple sessions, list them first: > ``` > screen -ls > ``` > Then resume the desired session: > ``` > screen -r session_id > ``` Comment [M](https://www.geeksforgeeks.org/user/Mandeep_Sheoran/) [Mandeep\_Sheoran](https://www.geeksforgeeks.org/user/Mandeep_Sheoran/) 9 Article Tags: Article Tags: [Linux-Unix](https://www.geeksforgeeks.org/category/linux-unix/) [linux-command](https://www.geeksforgeeks.org/tag/linux-command/) [Linux-misc-commands](https://www.geeksforgeeks.org/tag/linux-misc-commands/) ### Explore [![GeeksforGeeks](https://media.geeksforgeeks.org/auth-dashboard-uploads/gfgFooterLogo.png)](https://www.geeksforgeeks.org/) ![location](https://media.geeksforgeeks.org/img-practice/Location-1685004904.svg) Corporate & Communications Address: A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305) ![location](https://media.geeksforgeeks.org/img-practice/Location-1685004904.svg) Registered Address: K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305 [![GFG App on Play Store](https://media.geeksforgeeks.org/auth-dashboard-uploads/googleplay-%281%29.png)](https://geeksforgeeksapp.page.link/gfg-app)[![GFG App on App Store](https://media.geeksforgeeks.org/auth-dashboard-uploads/appstore-%281%29.png)](https://geeksforgeeksapp.page.link/gfg-app) - Company - [About Us](https://www.geeksforgeeks.org/about/) - [Legal](https://www.geeksforgeeks.org/legal/) - [Privacy Policy](https://www.geeksforgeeks.org/legal/privacy-policy/) - [Contact Us](https://www.geeksforgeeks.org/about/contact-us/) - [Advertise with us](https://www.geeksforgeeks.org/advertise-with-us/) - [GFG Corporate Solution](https://www.geeksforgeeks.org/gfg-corporate-solution/) - [Campus Training Program](https://www.geeksforgeeks.org/campus-training-program/) - Explore - [POTD](https://www.geeksforgeeks.org/problem-of-the-day) - [Job-A-Thon](https://practice.geeksforgeeks.org/events/rec/job-a-thon/) - [Blogs](https://www.geeksforgeeks.org/category/blogs/?type=recent) - [Nation Skill Up](https://www.geeksforgeeks.org/nation-skill-up/) - Tutorials - [Programming Languages](https://www.geeksforgeeks.org/computer-science-fundamentals/programming-language-tutorials/) - [DSA](https://www.geeksforgeeks.org/dsa/dsa-tutorial-learn-data-structures-and-algorithms/) - [Web Technology](https://www.geeksforgeeks.org/web-tech/web-technology/) - [AI, ML & Data Science](https://www.geeksforgeeks.org/machine-learning/ai-ml-and-data-science-tutorial-learn-ai-ml-and-data-science/) - [DevOps](https://www.geeksforgeeks.org/devops/devops-tutorial/) - [CS Core Subjects](https://www.geeksforgeeks.org/gate/gate-exam-tutorial/) - [Interview Preparation](https://www.geeksforgeeks.org/aptitude/interview-corner/) - [Software and Tools](https://www.geeksforgeeks.org/websites-apps/software-and-tools-a-to-z-list/) - Courses - [ML and Data Science](https://www.geeksforgeeks.org/courses/category/machine-learning-data-science) - [DSA and Placements](https://www.geeksforgeeks.org/courses/category/dsa-placements) - [Web Development](https://www.geeksforgeeks.org/courses/category/development-testing) - [Programming Languages](https://www.geeksforgeeks.org/courses/category/programming-languages) - [DevOps & Cloud](https://www.geeksforgeeks.org/courses/category/cloud-devops) - [GATE](https://www.geeksforgeeks.org/courses/category/gate) - [Trending Technologies](https://www.geeksforgeeks.org/courses/category/trending-technologies/) - Videos - [DSA](https://www.geeksforgeeks.org/videos/category/sde-sheet/) - [Python](https://www.geeksforgeeks.org/videos/category/python/) - [Java](https://www.geeksforgeeks.org/videos/category/java-w6y5f4/) - [C++](https://www.geeksforgeeks.org/videos/category/c/) - [Web Development](https://www.geeksforgeeks.org/videos/category/web-development/) - [Data Science](https://www.geeksforgeeks.org/videos/category/data-science/) - [CS Subjects](https://www.geeksforgeeks.org/videos/category/cs-subjects/) - Preparation Corner - [Interview Corner](https://www.geeksforgeeks.org/interview-prep/interview-corner/) - [Aptitude](https://www.geeksforgeeks.org/aptitude/aptitude-questions-and-answers/) - [Puzzles](https://www.geeksforgeeks.org/aptitude/puzzles/) - [GfG 160](https://www.geeksforgeeks.org/courses/gfg-160-series) - [System Design](https://www.geeksforgeeks.org/system-design/system-design-tutorial/) [@GeeksforGeeks, Sanchhaya Education Private Limited](https://www.geeksforgeeks.org/), [All rights reserved](https://www.geeksforgeeks.org/copyright-information/) ![]()
Readable Markdown
Last Updated : 11 Jul, 2025 The screen command is an advanced terminal multiplexer that allows you to have multiple sessions within one terminal window. It's like having "tabs" in your [Linux terminal](https://www.geeksforgeeks.org/linux-unix/linux-online-terminal/) — you can open, detach, switch, or resume sessions at any time without losing what you're working on. It's particularly convenient for system administrators, developers, or anyone working remotely. From executing lengthy installations to multi-tasking across multiple terminal windows, the screen command is easy to use, lightweight, and already present in most Linux installations such as Ubuntu, CentOS, or Debian. ## ****What is Screen Command**** The screen command for [Linux](https://www.geeksforgeeks.org/linux-unix/introduction-to-linux-operating-system/) is the remote control of your terminal. It lets you create, deal with, and reattach many terminal sessions in one window. If you ever lost work when your SSH connection dropped or internet went down, screen is your lifesaver tool. Imagine this — instead of having tens of open terminals and risking losing them on disconnect or power outage, you can begin a screen session and continue working at your leisure without having to begin from scratch. It is particularly valuable for system administrators, programmers, or anyone else dealing with Linux remotely. ### ****Key Features of the Linux Screen Command**** - ****Persistence of sessions****: Prevent programs from exiting even when logged out. - ****Multi-tasking assistance****: Have multiple terminal sessions open simultaneously. - ****Terminal splitting****: Look at logs in a window, code in another. - ****Ease of navigation****: Switch between screens with keyboard shortcuts. - ****Lightweight & pre-installed****: It comes with most Linux distros by default. ## What is the Screen Command Used For The screen command in Linux can be used for: - ****Running terminal sessions in the background****: It is ideal for scripts that are long-running, updates, downloads, or server configurations that will take hours. - ****Keeping programs running after you log out****: Despite your internet losing connection or terminating your terminal, the session silently runs in the background. - ****Quickly switch between several terminal windows****: It's similar to having several browser windows, but for your Linux command line. You don't need to leave the terminal to switch between tasks. - ****Reattach to previous sessions without losing work****: Whether you're on a different device or you just rebooted your computer, you can reconnect to your old terminal right where you left it. - ****Split your terminal window****: You can see system logs in one pane and edit files in another, all within the same screen session ****Syntax:**** ``` screen [-opts] [cmd [args]] ``` ## ****How to Install the Screen Command**** Most [Linux distros](https://www.geeksforgeeks.org/linux-unix/what-are-linux-distributions/) ([Ubuntu](https://www.geeksforgeeks.org/linux-unix/what-is-ubuntu/), Debian, [CentOS](https://www.geeksforgeeks.org/linux-unix/getting-started-with-centos/)) include `screen` ``` sudo apt install screen # For Debian/Ubuntu sudo yum install screen # For CentOS/RHEL ``` ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420104739/Screenshot-675.png) ## ****How to Use Them**** ### 1\. Start a New Screen Session To start a new terminal screen session: ``` screen ``` ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420112254/Screenshot-682.png) ### 2\. Name Your Session Naming a session helps you keep track of multiple sessions. ``` screen -S file ``` - ****\-S:**** It will start a new window within the screen and also gives a name to the window. It creates a session which is identified by that name. The name can be used to reattach screen at a later stage. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420232148/Screenshot-733.png) ### 3\. List All Running or Detached Screen Sessions To see which screen sessions are active or have been detached: ``` screen -ls ``` - ****\-ls:**** It is used to display the currently opened screens including those running in the background. It will list all the attached as well as detached screen sessions. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420231629/Screenshot-723.png) ### ****4\. Detach from a Screen Without Closing It**** You can safely leave a screen session running in the background by detaching it. ``` screen -d 1643 ``` - ****\-d:**** It is used to detach a screen session so that it can be reattached in future. It can also be done with the help of shortcut key **Ctrl-a + d.** Here **1643** is the screen id we want to detach. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420233218/Screenshot-743.png) ### 5\. Reattach to a Screen Session To resume work on a previously detached session: ``` screen -r 1643 ``` - ****\-r:**** It is used to reattach a screen session which was detached in past. ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420234423/Screenshot-752.png) ### ****Note:**** - To check for the manual page of screen command, use the following command: ``` man screen ``` - To check the help page of screen command, use the following command: ``` screen --help ``` ![](https://media.geeksforgeeks.org/wp-content/uploads/20190420235222/Screenshot-776.png) ## Commonly Used `screen` Command Options in Linux To use `screen` effectively, it's important to understand its command-line options. | ****Option**** | ****Description**** | |---|---| | **`-a`** | Forces all capabilities into each window's terminal capability (termcap). | | ****\`-A -\[r**** | R\]\` | | **`-c file`** | Uses a custom configuration file instead of the default `.screenrc`. | | **`-d (-r)`** | Detaches a running screen session from elsewhere and reattaches it here. | | **`-dmS name`** | Starts screen in ****detached**** mode with a session name (like a background task). | | **`-D (-r)`** | Detaches and logs out a remote session and reattaches it here. | | **`-D -RR`** | Does whatever is needed to connect to a screen session. | | **`-e xy`** | Changes the default control command characters. | | **`-f`** | Enables flow control. Use `-fn` to disable, or `-fa` for auto mode. | | **`-h lines`** | Sets the scrollback buffer size (number of history lines). | | **`-i`** | Interrupts output sooner when flow control is on. | | **`-l`** | Turns on login mode (updates `/var/run/utmp`). Use `-ln` to disable. | | **`-ls [match]`** | Lists all current screen sessions, with optional name match. | | **`-L`** | Enables output logging to a file. | | **`-m`** | Ignores the `$STY` variable; forces a new session to start. | | **`-O`** | Chooses optimized output over exact VT100 emulation. | | **`-p window`** | Pre-selects the named window when screen starts. | | **`-q`** | Starts screen quietly. Returns error code if it fails. | | **`-Q`** | Sends command output to the stdout of the calling process. | | **`-r [session]`** | Reattaches to a detached session (if it exists). | | **`-R`** | Reattaches to an existing session or starts a new one. | | **`-S sockname`** | Sets a custom session socket name (helpful for managing multiple sessions). | | **`-t title`** | Sets a window title (name of the terminal window). | | **`-T term`** | Uses a specific terminal type instead of the default `screen`. | | **`-U`** | Enables UTF-8 encoding support inside the session. | | **`-v`** | Prints screen version and build date. | | **`-x`** | Attaches to a session even if it's already attached (multi-display mode). | | **`-X`** | Executes a screen command in a specific session from outside. | ## Screen Command Shortcuts in Linux (Cheat Sheet) When working inside a `screen` session in Linux, you can navigate between windows, rename them, detach sessions, and more — all using quick keyboard shortcuts | Shortcut | Action (What It Does) | |---|---| | **`Ctrl-a + c`** | Create a new window inside the screen session. | | **`Ctrl-a + w`** | List all open windows within the current screen session. | | **`Ctrl-a + A`** | Rename the current window. Helpful when using multiple windows (visible in `Ctrl-a + w`). | | **`Ctrl-a + n`** | Go to the next window. | | **`Ctrl-a + p`** | Go to the previous window. | | **`Ctrl-a + Ctrl-a`** | Switch back to the last used window. | | **`Ctrl-a + k`** | Close (kill) the current window. | | **`Ctrl-a + S`** | Split the window horizontally. Switch with `Ctrl-a + Tab`. | | ****\`Ctrl-a +**** | ****\`**** | | **`Ctrl-a + X`** | Close the active split window. | | **`Ctrl-a + Q`** | Close all split windows. | | **`Ctrl-a + d`** | Detach the session (keeps it running in background). | | **`Ctrl-a + r`** | Reattach a previously detached session. | | **`Ctrl-a + [`** | Enter copy mode (use arrow keys to scroll and select). | | **`Ctrl-a + ]`** | Paste copied text inside the screen session. | ## Conclusion Linux's screen command is not just a tool — it's a multitasking lifesaver and remote session manager. If you're writing files, running background jobs, or watching system logs, screen keeps your work from being disrupted, even if your SSH connection is interrupted. By mastering screen, you take command of the way you work with the command line. You can detach sessions, pick up where you left off from another computer, or even split the terminal screen and work smarter. With its built-in shortcuts, session persistence, and lightweight footprint, it's no wonder screen remains a favorite among Linux power users. #### How to resume screen in Linux? > To resume a detached screen session, use the `screen -r` command followed by the session ID if there are multiple sessions: > ``` > screen -r > ``` > If there are multiple sessions, list them first: > ``` > screen -ls > ``` > Then resume the desired session: > ``` > screen -r session_id > ```
Shard103 (laksa)
Root Hash12046344915360636903
Unparsed URLorg,geeksforgeeks!www,/linux-unix/screen-command-in-linux-with-examples/ s443