tmux vs screen


2 minute read

image-center

Due to I have many services and servers on Raspberry Pi I need to spend some time after turning on and relaunching the RPi to start every service and server.

It emerged that screen is pretty good solution to my problem because it allows to run scripts and programs on boot of device1.

Before this I was always using tmux but its functionality doesn’t allow doing so – user has to login to launch every script and program in background tmux-sessions like I needed.

About tmux:

  • Create new session:
    tmux new -s <name>
    
  • Hide the session (detach from it): Ctrl+B then D
  • List all sessions:
    tmux ls
    
  • Attach to session:
    tmux a -t <name>
    
  • Close the session: Ctrl+B then X

About screen:

  • Run the command on background:
    screen -dmS <screen_name> "<command>"
    
  • Run the sequence of programs in background:
    screen -dmS <screen_name> bash -c "<command1>; <command2>; <command3>;"
    
  • Hide the session (detach from it): Ctrl+A then D
  • List all sessions:
    screen -list
    
  • Attach to session:
    screen -x <screen_name>
    
  • Close running in <screen_name> program:
    screen -S <screen_name> -X quit
    

  1. Running the scripts and programs in background on boot at homebridge repository
  2. More about screen command on Ubuntu
  3. tmux vs screen on Reddit’e
  1. Running the scripts and programs in background on boot at homebridge repository 

Leave a comment