How to change password in Linux by cmd

I am trying to change password in Linux for root but it says I don’t have permission. How can I changing the root password for Linux by cmd? I try

$ passwd root

For changing the toot password for Linux, follow these steps:

  1. Login to your server using the ssh
ssh user@server-ip
  1. At the command prompt (also know as shell prompt or bash shell), type the following command:
sudo passwd

OR

sudo passwd root
  1. Enter new password twice.

See my page for more info
https://www.cyberciti.biz/faq/linux-change-password/

1 Like

You can use below command:
sudo passwd username

You can replace username with the name of user whose password you had to change.

1 Like

Is your username is sudoers?

if not! Try to access the root by:

su -

Then enter the root password.

Now you are in root account! Change password by using:

passwd root #using without sudo is fine
1 Like