For an example on the /etc/shadow files you may think of it this way: Get actual cripted password salt from shadow: $salt = substr($password_string_from_shadow, 0, 2); $newpass = $salt . crypt($string_i_think_is_password,$salt); $newpass is now a string you can push back to password file...