Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using screen (LINUX) to run servers or task, but I want to put more than one task in one screen, is it impossible? Like:

screen -A -m -d -S test_screen userdel -r user_test && useradd -m -p 'encrypt_pass' user_test

How to change && because it leads first task left in screen and another execute in display and "" doesn't help, too.

I want to do it that each task executes one after the other.

share|improve this question
up vote 1 down vote accepted

Try this screen -A -m -d -S test_screen sh -c "userdel -r user_test && useradd -m -p 'encrypt_pass' user_test"

Encasing the command in sh -c "" runs the whole command in the default shell

share|improve this answer

Put all commands you want to execute into a shell script and run it with screen.

share|improve this answer

Several ideas:

  1. Put the commands in a script, run the script from within the screen.
  2. Use subshell (i.e. put the commands inside ( ) )
  3. Use bash -c 'command a && command b' as the command to be run by screen
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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