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 am writing notes as I prepare a system so I have something to follow if/when I need to prepare another system. Also I am hoping to use these notes and implement into a puppet configuration at some point.

I am trying to write multi-line bash commands, but when I copy and paste from my IDE (aptana) into the terminal, I get weird behavior and the commands never execute, even though when I step back in history the multi-line command looks like I entered it manually.

My question is, how can I save the commands in a multi-line format so I can quickly copy and paste into the terminal?


$ "mkdir -p /var/log/php && \
 chown -R apache /var/log/php && \ 
 chgrp -R webdev /var/log/php && \
 chmod -R 775 /var/log/php && \ 
 touch /var/log/php/oops.log"

touch /var/log/php/oops.log: No such file or directory
share|improve this question
up vote 2 down vote accepted

Bash control operators (such as &&) do NOT require a " \" to concatenate lines together. You also do not need to quote your script. The re-factored version would be:

mkdir -p /var/log/php && 
/bin/chown -R apache /var/log/php &&  
/bin/chgrp -R webdev /var/log/php && 
/bin/chmod -R 775 /var/log/php &&  
touch /var/log/php/oops.log

Cutting and pasting that script in a shell should work.

share|improve this answer
Interesting, I thought I tried this combo, apparently not. Your solution worked. Thanks! – Mike Purcell Dec 13 '11 at 1:50

You could use exec:

$ exec <<< "echo hello world"

BUT keep in mind, it will exit your current shell once done. You could address this by spawning a new shell:

$ bash -s <<< "echo hello world"

Also, you could make it a bash script. Example:

mkdir -p /var/log/php
chown -R apache /var/log/php
chgrp -R webdev /var/log/php
chmod -R 775 /var/log/php
touch /var/log/php/oops.log

You could do something like:

$ cat >> ~/
mkdir -p /var/log/php
chown -R apache /var/log/php
chgrp -R webdev /var/log/php
chmod -R 775 /var/log/php
touch /var/log/php/oops.log
$ . ~/
share|improve this answer
Was considering that... Just wanted to see if it was possible to copy and paste straight into the terminal first. – Mike Purcell Dec 13 '11 at 1:47
Ah, you could address the spawning by opening a new shell. Thanks @Pascal.Charest. – Belmin Fernandez Dec 13 '11 at 2:22

You simply do the first four commands by doing...

$ install -o apache -g webdev -m 0755 -d /var/log/php

This will create a directory /var/log/php with owner apache group webdev and permission 0755.

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.