Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'bash -c' do?

Tags:

linux

bash

I followed the following tutorial: http://davidtsadler.com/archives/2012/06/03/how-to-install-magento-on-ubuntu/

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 www.localhost.magento-store.com    DocumentRoot /home/dev/public_html/magento-store.com/public    LogLevel warn   ErrorLog  /home/dev/public_html/magento-store.com/log/error.log   CustomLog /home/dev/public_html/magento-store.com/log/access.log 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.

like image 565
giannisapi Avatar asked Dec 31 '13 13:12

giannisapi


People also ask

What is in bash used for?

People use Bash when they want to control their computer or OS without having to navigate menus, options, and windows within a GUI. As we pointed out earlier, with CLIs like Bash, you usually don't even need to use your mouse. You can navigate through your computer's OS without your fingers ever leaving your keyboard.

What is bash what is its purpose?

Bash is a legitimate interface to your computer, and it's not just for server admins and programmers. It can be your desktop, your word processor, your graphics editing application, and much, much more. Some people use Bash more than they use desktop apps.

Why does Linux use bash?

Software developers rely on Bash for many development tasks. Bash can be used to automate software development tasks such as code compilation, debugging source code, change management and software testing. Network engineers use Bash to test, configure and optimize network performance on organizational networks.


2 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.

like image 80
devnull Avatar answered Sep 28 '22 01:09

devnull


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.

like image 30
lightandlight Avatar answered Sep 28 '22 01:09

lightandlight