Introduction
The Linux Screen command is an essential tool for system managers and developers who need to keep terminal sessions active despite disconnections, SSH closures or temporary restarts. In this article we will explore what it is, how to install it, create and manage persistent sessions, and some tricks to make the most of it. In the end you will have a practical knowledge that will allow you to work more safely and efficiently in remote environments. In addition, Screen is light, does not require root privileges for basic use and is available in most distributions such as Ubuntu, Debian, CentOS and Fedora.
What is Screen
Screen is a terminal multiplexor that allows you to create one or more windows within a single command line session. Each window works as an independent terminal, but all share the same parent process, which facilitates its administration. When you start Screen, a session is created that remains active on the server even if you close your SSH client; by reconnecting you can resume exactly where you left off. This feature is particularly useful for long tasks such as compilations, downloads, or log monitoring, as it prevents job loss by unexpected interruptions. In addition, screen allows to share sessions among several users, which facilitates real-time collaboration without the need for external tools.
Screen installation
In most Linux distributions, Screen is in the official repositories and its installation is simple. In Debian / Ubuntu-based systems, just run sudo apt update and sudo apt install screen. In Red Hat, CentOS or Fedora dnf install screen or yum install screen is used according to the version. After installation, you can check that the command is available by writing screen -version, which will show the installed version number. No additional configuration steps are required to start using it, although there is an optional configuration file ~/ .screenrc to customize shortcuts and behavior.
Start a session
To start a new screen session, simply write screen in the prompt. A welcome screen will appear that you can press Enter to skip and move directly to the terminal. From that moment on, you're inside a screen session and you can run any command as you would in a normal terminal. If you want to name the session to identify it more easily later, use the screen-S command. For example, screen -S compilation _ java will create a session called compilation _ java that you can resume later with the same identifier. You can also start screen with a log by adding -L, which will save everything that is shown in the session in a file called Screenlog.0 in the current directory, useful for audit or debugging.
Disconnect and reconnect
One of the greatest advantages of screen is the ability to disconnect (detach) the session without finishing the processes that are running within it. To do so, press Ctrl + a followed by d. The session will be in the background and you can close your SSH client or close the local terminal without losing anything. To reconnect you (reattach) to the session, use the screen -r command. If you have several active sessions, screen -r will show you a list to choose the one you want to resume, or you can specify the name with screen -r name _ session. If the session is disconnected but another user has it connected, you can use -x to attach you in shared mode, allowing both to see the same output in real time.
Manage multiple windows
Within a screen session you can create multiple windows, each with its own shell, similar to the tabs of a browser. To create a new window, press Ctrl + a followed by c. To change between windows, use Ctrl + a and then the window number (0-9) or Ctrl + a n to go to the next and Ctrl + a p for the previous one. You can name each window with Ctrl + a A, which makes it easier to identify its purpose, for example, one for code editing, one for log monitoring and one third for a database console.
Useful shortcuts and configuration
Screen offers a wide set of shortcuts that accelerate daily work. Some of the most used are: Ctrl + a? to show help, Ctrl + a K to kill the current window, Ctrl + a followed by the inverted bar key to finish the entire session, and Ctrl + a: to enter the command mode where you can run orders like resize or focus. In addition, you can customize the behavior by using the file ~/ .screenrc: define a state bar with even predictable hardstatus, change the exhaust key (default Ctrl + a) to another combination, or activate the automatic record of all sessions. These settings make Screen fit your workflow and your team's policies.
- Ctrl + a?: shows the help
- Ctrl + a c: create a new window
- Ctrl + a d: disconnect the session
- Ctrl + a K: kills the current window
- Ctrl + a + inverted bar: end the entire session
- Ctrl + a:: enters command mode
Conclusion and best practices
In short, Screen is a light and powerful solution to maintain persistent terminal sessions in Linux, especially valuable when working through SSH or on remote servers. Its disconnection features, multiple windows and flexible configuration make it an essential tool for administrators, developers and anyone who needs to avoid job loss by interruptions. Always remember to name your sessions, use the activity log when necessary and periodically review the file ~/ .screenrc to maintain a clean and safe environment. With this knowledge, you can improve your productivity and the reliability of your tasks in the command line.


