What does 'bash -c' do?

I followed the following tutorial:

At some point it told me to execute the following command:

sudo bash -c "cat >> /etc/apache2/sites-available/magento-store.com <<EOF
<VirtualHost *:80> ServerName localhost.magento-store.com ServerAlias DocumentRoot /home/dev/public_html/ LogLevel warn ErrorLog /home/dev/public_html/ CustomLog /home/dev/public_html/ combined
</VirtualHost>
EOF"

What did this command do, and how I can cancel that?

I restarted the computer, and it seems that it is still running. I looked in .bashrc and .profile, but I did not find it inside.

3

3 Answers

Quoting from man bash:

-c string If the -c option is present, then commands are read from string.
If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

The command quoted by you would append the text in heredoc (i.e. the text in VirtualHost tag) to the file /etc/apache2/sites-available/magento-store.com.

9

The manual page for Bash (e.g. man bash) says that the -c option executes the commands from a string; i.e. everything inside the quotes.

Check out the man pages, either on your machine or on the Internet, like this one.

Quote:

-c string If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like