الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

vipw

Edit /etc/passwd (vipw) or /etc/group (vigr) safely by hand, with a lock.

المستوى
لينكس اليومي
المجموعة
المستخدمون والمجموعات
يحتاج root
نعم
الحزمة
shadow-utils
يُسمّى أيضًا
vigr

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

vipw and vigr open a copy of the account file in your editor ($VISUAL, $EDITOR or vi) and lock the file, so passwd, useradd and others cannot change it at the same time. When you save, the copy replaces the real file.

After editing /etc/passwd you are asked to edit /etc/shadow too (and after /etc/group also /etc/gshadow), so both stay in sync.

Most work is easier and safer with useradd, usermod and groupmod. Use vipw/vigr for fixes those tools cannot do.

طريقة الكتابة

vipw [OPTION]...
vigr [OPTION]...

الخيارات 6

الأكثر استخدامًا

-p, --passwd
Edit the passwd file (default of vipw).
-g, --group
Edit the group file (default of vigr).
-s, --shadow
Edit the shadow file (/etc/shadow or /etc/gshadow).
-q, --quiet
Quiet mode.
-R, --root DIR
Work in this chroot folder.
-h, --help
Show help.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Edit the user file

    vipw

    Opens /etc/passwd with a lock; afterwards it offers to edit /etc/shadow.

  2. 2Edit the group file

    vigr

    Opens /etc/group with a lock.

  3. 3Edit the shadow file directly

    vipw -s

    For example to fix a wrong aging field.

  4. 4Edit the group shadow file

    vigr -s

    Group passwords and group admins.

  5. 5Use nano as the editor

    EDITOR=nano vipw

    Any editor works.

  6. 6Check the files after a manual edit

    pwck -r; grpck -r

    -r = only report, change nothing.

  7. 7Fix a wrong login shell by hand

    vipw

    Change the last field, for example /bin/bsh back to /bin/bash.

  8. 8Find a second root account (security)

    awk -F: '$3 == 0 {print $1}' /etc/passwd
    root

    Only root may have UID 0. Another name here means a backdoor.

  9. 9Find accounts without a password hash (security)

    awk -F: '$2 == "" {print $1}' /etc/shadow

    Empty field = login without a password. Fix it at once.

  10. 10Make a backup before a manual edit

    cp -a /etc/passwd /etc/shadow /etc/group /root/

    The tools also keep a copy: /etc/passwd- and /etc/group-.

  11. 11See the lock files during an edit

    ls /etc/*.lock

    /etc/passwd.lock exists while vipw is open.

انتبه

  • Never edit /etc/passwd or /etc/shadow with a normal editor while the system runs.
  • A broken line can stop logins for everybody. Keep a root shell open while you test.

الملفات

/etc/passwd, /etc/shadow, /etc/group, /etc/gshadow
The files that are edited.
/etc/passwd-, /etc/group-
Backup copies from the last change.

رموز الخروج

0Done.
1Error (file busy or the editor failed).

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man 8 vipw