title: Linux set root password on etc/shadow file
body: <p>I'm building a ram filesystem, and I generated a "/" directory. I would like to set a default root password on the generated "etc/shadow" file.
  The actual file is:</p>
  
  <pre><code>root:*:15980:0:99999:7:::
  bin:*:15980:0:99999:7:::
  daemon:*:15980:0:99999:7:::
  adm:*:15980:0:99999:7:::
  ...
  .....
  </code></pre>
  
  <p>I would like to replace "root:*:" with "root:Hashedpassword:", I know it is very easy to replace "*" with the "HASHEDPASSWORD", But it should by done using the pattern "root:anything:", and this also should not be difficult, even-though I would like to ask about it here coz it may be useful for others.</p>
  
  <p>For example:</p>
  
  <p>the password I want to set is "centos"</p>
  
  <p>The salt is "xyz"</p>
  
  <p>I get the hashed pass:</p>
  
  <pre><code>pass=$(openssl passwd -1 -salt xyz centos)
  </code></pre>
  
  <p>Then I would like te replace "anything" in "root:anything:" with "root:Hashedpassword:" with "sed" command.</p>