Last Updated: January 28, 2019
· blainesch

Sending Command to Vagrant - Undocumented Flag

Often times we want to run a single command in Vagrant, but doing this seems to take too long:

-> vagrant ssh
Last login: Fri Jul 12 14:55:21 2013 from
Welcome to your Vagrant-built virtual machine.

-> sudo service httpd restart
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]

-> exit

Instead, why not send the single command straight to Vagrant. Using the undocumented "-c" flag you can send a command straight to vagrant.

-> vagrant ssh -c 'sudo service httpd restart'
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]

3 Responses
Add your response

over 1 year ago ·

@walesmd I'm not sure how long it's been on those documents, but they still don't show up when I do vagrant --help or man vagrant. Thanks for letting me know!

over 1 year ago ·

For help on any individual command run vagrant COMMAND -h
For example: vagrant ssh -h
Usage: vagrant ssh [vm-name] [-c command] [-- extra ssh args]

-c, --command COMMAND            Execute an SSH command directly.
-p, --plain                      Plain mode, leaves authentication up to user.
over 1 year ago ·