هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
chpasswd reads lines in the form USER:PASSWORD and sets each password, hashed with the method of /etc/login.defs (SHA-512 or yescrypt). It is the standard way to set passwords in scripts, Kickstart %post sections and provisioning tools, because it works the same on every Linux. With -e the passwords are already hashes.
طريقة الكتابة
chpasswd [OPTION]...
echo 'USER:PASSWORD' | chpasswdالخيارات 7
الأكثر استخدامًا
Options
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 10
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Set one password in one line
echo 'mia:RedHat-2026' | chpasswd2Set many passwords from a file
cat newpasswords.txt mia:Start-2026-a leo:Start-2026-b sara:Start-2026-c chpasswd < newpasswords.txt shred -u newpasswords.txtRemove the clear-text file at once.
3Create users and set passwords in a loop
4Force a password change at the first login
5Use a prepared hash (no clear text on the server)
6Choose the hash method
echo 'leo:Long-Passphrase-2026' | chpasswd -c SHA5127Set the root password inside a mounted system
echo 'root:Recovery-2026' | chpasswd -R /mnt/sysroot8Random passwords for a list of users, saved for hand-over
9Check that the password was set
10Kickstart %post example
cat ks-post.txt %post echo 'admin:Change-me-2026' | chpasswd chage -d 0 admin %end
لا يوجد شيء يطابق هذا الفلتر.
انتبه
- Passwords typed on the command line land in the shell history. Use a file with rights
600, orchpasswd -ewith a hash. pwqualityrules are not checked bychpasswdwhen root runs it.
الملفات
/etc/shadow- Where the hashes are stored.
/etc/login.defsENCRYPT_METHOD(default hash method).
نصائح للحفظ
chpasswdis the safe replacement forpasswd --stdinin scripts: it works on every distribution.
رموز الخروج
0 | Success. |
1 | Error (unknown user, bad line, no rights). |