As the title says, I would like to set up GNU screen on my headless box such that when it starts up with some screens already running.

My .bashrc file runs screen on the first login with screen -xRR and I would like htop and various logs to be automatically opened.

Is it also possible to assign titles to the screens at the same time?


2 Answers 2


You can define default windows in your Screen configuration file, ~/.screenrc.

Window titles can be set inline with the -t option, but working directories must be set in advance of launching each window. For example, in your case you might include the following:


# ...

chdir ~
screen -t "Htop" htop

chdir /var/log
screen -t "System log" tail -F syslog
screen -t "Mail log" tail -F mail.log

chdir ~
screen   # Extra Bash window for running commands

# ...

Note that the screen here is not the screen command you run, but an internal screen command. See man screen, section on Customization, or the GNU manual for more.


You could take advantage of the -S flag, and provide a unique name you'd like to give the screen.

screen -S MyTitleHere

You can also load configuration files, using the -c flag.

screen -S foo -c /home/user/.screenrc.bar

You could try something such as:

su -c "screen -dm -S $TITLE 2>&1 1>/dev/null" $USER

And place it in your /etc/rc.local, which would cause that screen to be created when you boot up for a specific user.

Once you get your configuration (.rc) files set up, you'll probably want to run something along the lines of:

screen -dURS $TITLE -c /path/to/.screenrc.bar

As this will

  1. Create the screen session if it doesn't exist
  2. Re-Attach to the session if it already exists.

Another option would be to use tmux and tmuxinator, which provide a cleaner experience, in my opinion. You can set up tmux to use the screen-style keybindings, if you're used to that. I say this because I've had much better success running tmux for other users than I have had with screen.

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.