Answers: <p>Just to state the obvious for junior folks who might come across this: <code>sudo shutdown now</code> requires access to the operating system (via SSH keys, inbound security groups, etc), while <code>aws ec2 stop-instances</code> is an <a href="https://aws.amazon.com/cli/" rel="nofollow noreferrer">AWS CLI</a> command which simply requires API authentication (via IAM credentials or STS tokens).</p>
  <p>Aside from the obvious difference in invocation, the shutdown is the same.</p>
  <blockquote>
  <p>When you stop or hibernate an instance, we shut it down. You can restart your instance at any time. Before stopping or hibernating an instance, make sure it is in a state from which it can be restarted. Stopping an instance does not preserve data stored in RAM, but hibernating an instance does preserve data stored in RAM. If an instance cannot hibernate successfully, a normal shutdown occurs.</p>
  </blockquote>
  <p>Source: <a href="https://docs.aws.amazon.com/cli/latest/reference/ec2/stop-instances.html" rel="nofollow noreferrer">stop-instances documentation</a></p>
  <p>The <code>--hibernate</code> flag defaults to <code>false</code>, so a normal shutdown is triggered immediately by your CLI command.</p>
  <p>When <code>--hibernate</code> is <code>true</code>, the suspend-to-disk process differs from a regular shutdown (such as <code>sudo shutdown now</code>), and is further documented <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html" rel="nofollow noreferrer">here</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-01-22T07:05:30.687Z
Answers: This answer seems incomplete to me.  In stating "the shutdown is the same", are you saying that from the perspective of the OS running in the instance, the two shutdowns behave identically?  If you are saying that, then I see nothing here to back up that statement.  Shutting down a Linux instance via `sudo shutdown now` is well understood.  What does a shutdown look like from the OS's perspective when the instance is stopped via the AWS CLI?  If the two are **the same**, EC2 must then gain a command prompt as root on the instance and execute a "sudo shutdown now"? Is that what happens?
Answers: CryptoFool
Answers: CC BY-SA 4.0
Answers: 2021-01-22T07:10:18.750Z
Answers: ...if the two shutdowns are not actually **the same**, then this not an answer to the question, as it does not describe how the two operations differ.  If the two operations are still **nearly identical**, then maybe this answer is substantively correct.  However, I think that needs to be clearly stated.  As it is, this answer provides me with no confidence that I may use the two operations interchangeably and assume no difference in result.
Answers: CryptoFool
Answers: CC BY-SA 4.0
Answers: 2021-01-19T22:50:09.587Z
Answers: 2021-01-19T22:50:09.587Z
Answers: Woodland
Body: <p>When logged onto a AWS EC2 instance say some Ubuntu box and I issue</p>
  <pre><code>sudo shutdown now
  </code></pre>
  <p>how is that different from stopping the same instance using</p>
  <pre><code>aws ec2 stop-instances --instance-ids  $curr_instanceid --region $AWS_REGION
  </code></pre>
  <p>either way I see the instance gets into the state of <code>stopped</code> and it will transition into state <code>running</code> once this is run</p>
  <pre><code>aws ec2 start-instances --instance-ids   $curr_instanceid --region $AWS_REGION
  </code></pre>
  
Tags: <amazon-ec2>
Title: what is difference between "sudo shutdown now" versus "aws ec2 stop-instances"
UserDisplayName: Scott Stensland
ThreadText: # what is difference between "sudo shutdown now" versus "aws ec2 stop-instances"
  
  (Asked by: username_0 on 2021-01-18)
  
  When logged onto a AWS EC2 instance say some Ubuntu box and I issue
  
  ```
  sudo shutdown now
  
  ```
  
  how is that different from stopping the same instance using
  
  ```
  aws ec2 stop-instances --instance-ids  $curr_instanceid --region $AWS_REGION
  
  ```
  
  either way I see the instance gets into the state of `stopped` and it will transition into state `running` once this is run
  
  ```
  aws ec2 start-instances --instance-ids   $curr_instanceid --region $AWS_REGION
  
  ```
  
  **Tags:** amazon-ec2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-19. Score: 1 | Accepted answer
  
  Just to state the obvious for junior folks who might come across this: `sudo shutdown now` requires access to the operating system (via SSH keys, inbound security groups, etc), while `aws ec2 stop-instances` is an [AWS CLI](https://aws.amazon.com/cli/) command which simply requires API authentication (via IAM credentials or STS tokens).
  
  Aside from the obvious difference in invocation, the shutdown is the same.
  
  > When you stop or hibernate an instance, we shut it down. You can restart your instance at any time. Before stopping or hibernating an instance, make sure it is in a state from which it can be restarted. Stopping an instance does not preserve data stored in RAM, but hibernating an instance does preserve data stored in RAM. If an instance cannot hibernate successfully, a normal shutdown occurs.
  
  Source: [stop-instances documentation](https://docs.aws.amazon.com/cli/latest/reference/ec2/stop-instances.html)
  
  The `--hibernate` flag defaults to `false`, so a normal shutdown is triggered immediately by your CLI command.
  
  When `--hibernate` is `true`, the suspend-to-disk process differs from a regular shutdown (such as `sudo shutdown now`), and is further documented [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html).
  
  > **Comments:**
  > **username_2**: This answer seems incomplete to me.  In stating "the shutdown is the same", are you saying that from the perspective of the OS running in the instance, the two shutdowns behave identically?  If you are saying that, then I see nothing here to back up that statement.  Shutting down a Linux instance via `sudo shutdown now` is well understood.  What does a shutdown look like from the OS's perspective when the instance is stopped via the AWS CLI?  If the two are **the same**, EC2 must then gain a command prompt as root on the instance and execute a "sudo shutdown now"? Is that what happens?  
  > **username_2**: ...if the two shutdowns are not actually **the same**, then this not an answer to the question, as it does not describe how the two operations differ.  If the two operations are still **nearly identical**, then maybe this answer is substantively correct.  However, I think that needs to be clearly stated.  As it is, this answer provides me with no confidence that I may use the two operations interchangeably and assume no difference in result.  
  
  ---
  
  