{"id":1336,"date":"2018-12-24T07:01:15","date_gmt":"2018-12-24T01:31:15","guid":{"rendered":"http:\/\/jaipurhosting.com\/blog\/?p=1336"},"modified":"2019-04-27T07:32:37","modified_gmt":"2019-04-27T02:02:37","slug":"linux-chpasswd-command","status":"publish","type":"post","link":"https:\/\/www.jaipurhosting.com\/blog\/linux-chpasswd-command\/","title":{"rendered":"Linux chpasswd Command"},"content":{"rendered":"\n<p><strong>Linux chpasswd command<\/strong><\/p>\n\n\n\n<p>The chpasswd command in Linux lets you update passwords in batch mode.<\/p>\n\n\n\n<p>Following is its syntax:<\/p>\n\n\n\n<p><em><strong>chpasswd [options]<\/strong><\/em><\/p>\n\n\n\n<p>And here\u2019s what the tool\u2019s man page says about it:<\/p>\n\n\n\n<p><em><strong>The chpasswd command reads a list of user name and password pairs from<br> standard input and uses this information to update a group of existing<br> users. Each line is of the format:<\/strong><\/em><\/p>\n\n\n\n<p><em><strong>user_name:password<\/strong><\/em><\/p>\n\n\n\n<p><i><b>By default the passwords must be supplied in clear-text, and are<br> encrypted by chpasswd. Also the password age will be updated, if<br> present.<\/b><\/i><\/p>\n\n\n\n<p>Following are some examples that should give you a good idea on how chpasswd works.<br> <\/p>\n\n\n\n<p><strong>To use chpasswd command<\/strong><\/p>\n\n\n\n<p>Basic usage, as explained in the introduction section above, is pretty straight forward. Just run the chpasswd command (with root privileges) sans any option, and enter the new password in \u2018username:password\u2019 format.<\/p>\n\n\n\n<p>For example, I executed the command:<br><em><strong> $ chpasswd<\/strong><\/em><\/p>\n\n\n\n<p>Note1: As chpasswd expects you to enter the input on stdin, don\u2019t forget to press Ctrl+D once you\u2019re done entering usernames and new passwords.<\/p>\n\n\n\n<p>Note2: The passwords used in the example here are just for demo purposes, don\u2019t use them in any way.<br> <\/p>\n\n\n\n<p><strong>To make chpasswd read information from file<\/strong><\/p>\n\n\n\n<p>Sometimes, you may want the tool to read input information from a file (rather than stdin). This can be done in the following way:<\/p>\n\n\n\n<p><em><strong>cat [FILENAME] | chpasswd<\/strong><\/em><\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<p><em><strong>cat newpass.txt | chpasswd<\/strong><\/em><\/p>\n\n\n\n<p>Note that the format of input remains the same: \u2018username:password\u2019, just that it\u2019s written in a file now.<br> <\/p>\n\n\n\n<p><strong>chpasswd handles encryption<\/strong><\/p>\n\n\n\n<p>Here\u2019s how the tool\u2019s man page explains this:<\/p>\n\n\n\n<p><em><strong>By default, passwords are encrypted by PAM, but (even if not<br> recommended) you can select a different encryption method with the -e,<br> -m, or -c options.<\/strong><\/em><\/p>\n\n\n\n<p><em><strong>Except when PAM is used to encrypt the passwords,chpasswd first updates<br> all the passwords in memory, and then commits all the changes to disk<br> if no errors occurred for any user.<\/strong><\/em><\/p>\n\n\n\n<p><em><strong>When PAM is used to encrypt the passwords (and update the passwords in<br> the system database) then if a password cannot be updated chpasswd<br> continues updating the passwords of the next users, and will return an<br> error code on exit<\/strong><\/em>.<\/p>\n\n\n\n<p><em><strong>This command is intended to be used in a large system environment where<br> many accounts are created at a single time.<\/strong><\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>To enable a different encryption method<\/strong><\/p>\n\n\n\n<p>This can be done using the -c command line option. By default, as you may already know by now, PAM is used as the encryption method, but using -c, you can specify any of the following: DES, MD5, NONE, and SHA256 or SHA512 (provided your libc supports the method you choose).<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<p><em><strong>chpasswd -c DES<\/strong><\/em><\/p>\n\n\n\n<p><strong>To tell chpasswd about encrypted input<\/strong><\/p>\n\n\n\n<p>If you want, you can also supply encrypted passwords in input. But for that, you need to use the -e option so that chpasswd knows about this.<\/p>\n\n\n\n<p><em><strong>chpasswd -e<\/strong><\/em><\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>The chpasswd command is usually used by system admins or persons entrusted with user management on a Linux PC or a network, although there\u2019s no harm in learning about it even if you are a normal user. Here, we\u2019ve discussed several major command line options of this tool. To learn more, head to its man page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux chpasswd command The chpasswd command in Linux lets you update passwords in batch mode. Following is its syntax: chpasswd [options] And here\u2019s what the tool\u2019s man page says about it: The chpasswd command reads a list of user name and password pairs from standard input and uses this information to update a group of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1339,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-categorized"],"_links":{"self":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=1336"}],"version-history":[{"count":1,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1336\/revisions"}],"predecessor-version":[{"id":1338,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/posts\/1336\/revisions\/1338"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media\/1339"}],"wp:attachment":[{"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=1336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=1336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jaipurhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=1336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}