# 02-B.10: Users: Create, Modify, and Delete - Edit etc passwd File

## Modify /etc/passwd and /etc/Group Files

### The vipw Command

The vipw command edits the files /etc/passwd. The command sets appropriate locks to prevent corruption by others attempting to make changes to the file during the editing session. The programs attempt to determine the proper editor, by first trying the environment variable $VISUAL, then the environment variable$EDITOR, and finally the default editor which is vi.

Syntax:

vipw [ OPTION ]


NOTICE: the user does NOT specify a filename...there are no arguments.

Command Options:

 Options Option Meaning -g, --group Edit group database. -h, --help Display help message and exit. -p, --passwd Edit passwd database. -q, --quiet Quiet mode. -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.

To safely edit the /etc/password file, simply run:

### The userdel Command

The userdel command in Linux system is used to delete a user account and related files. This command basically modifies the system account files, deleting all the entries which refer to the username LOGIN. It is a low-level utility for removing the users.

Syntax:

userdel [ OPTIONS ] USER_LOGIN


Command Options:

 Options Option Meaning -f, --force This option forces the removal of the user account, even if the user is still logged in. -r, --remove Files in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually.

With few options the command is quite simple:

pbmac@pbmac-server \$ userdel -f pbmac


This will force the user pbmac to be removed from the system.