linux change user password

C++
passwd $user#if you dont't have your root password => then don't use sudo command

# passwd <username>
Current password:
New password:
Retype new password:
passwd: password updated successfully# sudo passwd <username>
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Source

Also in C++: