Linux vipw and vigr command

Updated: 11/06/2021 by Computer Hope
vipw command

On Unix-like operating systems, the vipw and vigr commands are used to edit the password, group, shadow-password, and shadow-group files.

This page covers the Linux versions of vipw and vigr.

Description

The vipw and vigr commands edit the files /etc/passwd and /etc/group, respectively. If the -s flag is specified, these commands will edit the shadow (secure) versions of their files: /etc/shadow and /etc/gshadow, respectively. The programs sets the appropriate locks to prevent file corruption. When looking for an editor, the programs will first try the environment variable $VISUAL, then the environment variable $EDITOR, and finally the default editor, vi.

Syntax

vipw [options]
vigr [options]

Options

-g, --group Edit group database.
-h, --help Display help message and exit.
-p, --passwd Edit passwd database.
-q, --quiet Operate quietly.
-R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-s, --shadow Edit shadow or gshadow database.

Environment

The following environment variables affect the operation of the vipw and vigr commands:

VISUAL The editor to use.
EDITOR The editor to use if VISUAL is not set.

Files

/etc/group Group account information.
/etc/gshadow Secure group account information.
/etc/passwd User account information.
/etc/shadow Secure user account information.

Examples

vipw

Edit /etc/passwd.

vigr

Edit /etc/group.

vipw -s

Edit /etc/shadow.

vigr -s

Edit /etc/gshadow.

addgroup — Add a group to the system.
adduser — Add a group to the system.
groupadd — Add a group to the system.
useradd — Add a user to the system.
passwd — Change a user's password.
vi — Text editor based on the visual mode of ex.
visudo — Safely edit the sudoers file.