On an embedded device with BusyBox installed I want to set it up so that the gnu screen command is automatically started when any BusyBox session is started.

I have seen that I can add the screen command into the /etc/profile file but are there any other ways of doing this?


If you are using ssh you can just have it run instead of the shell (the default) when you connect.

ssh -t me@host screen -RD

That will create a new session of one does not exist, or otherwise connect to an existing session.

The -t flag to ssh tells to to create a pty even though it is not starting a shell. You need that for interactive use.


Add exec screen -R at the end of ~/.profile on the device: every time you log in, your session will reattach the last-created screen session. More precisely, to avoid launching screen in non-interactive sessions where you want to read your .profile to set environment variables, use this:

case $- in *i*) exec screen -R;; esac

You will still be able to avoid attaching to screen in an interactive session by running ssh -t bash -i as this will skip your .profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.