Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

vipw

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

Niveau
Dagelijks Linux
Groep
Gebruikers en groepen
Root nodig
Ja
Pakket
shadow-utils
Ook
vigr

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

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.

Zo schrijf je het

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

Opties 6

Meest gebruikt

-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.

Voorbeelden 11

$ als gewone gebruiker# als root (of met 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.

Let op

  • 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.

Bestanden

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

Exitcodes

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

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man 8 vipw