# Pipe Password to Sudo

So while trying to create an automated script for Docker to start running my container, I need to pass root's password to sudo in order to run `docker start _containerID_`. The way to do is given below -

```bash
echo "YOUR_PASSWORD_HERE" | sudo -S {COMMAND_TO_RUN_AS_ROOT}
```

The command to start Docker service was -

```bash
echo "SECRET" | sudo -S service docker start
```

And that was all, for me to pass the password to `sudo` without actually writing the password again!

Thing to note here is that passing `-S` makes `sudo` to read password from *stdin*.

***Original Question on*** [***Unix - StackExchange***](https://unix.stackexchange.com/questions/391796/pipe-password-to-sudo-and-other-data-to-sudoed-command)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/linux/pipe-password-to-sudo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
