vipw和vigr命令


  Modifying the Configuration Files  

      To add user accounts, it suffices that one line is added to /etc/passwd and another line is added to /etc/shadow, in which the user account and all of its properties are defined. It is not recommended, though. By making an error, you might mess up the consistency of the file and make logging in completely impossible to anyone. Also, you might encounter locking problems if one administrator is trying to modify the file contents directly while another administrator wants to write a modification with some tool.  

      If you insist on modifying the configuration files directly, you should use  vipw . This command opens an editor interface on your configuration files, and more important, it sets the appropriate locks on the configuration files to prevent corruption. It does  not  check syntax, however, so make sure that you know what you are doing because even by making a typo you might still severely mess up your server. If you want to use this tool to modify the /etc/shadow file, use  vipw -s . To edit the contents of the /etc/group file where groups are defined, a similar command with the name   vigr  exists.   
NOTE     It is nice to know that vipw and vigr exist, but it is better not to use these utilities or anything else that opens the user and group configuration files directly. Instead, use tools like useradd and groupmod.  

這兩個命令最主要就是會給文件加鎖!以免在編輯文件時!其他用戶也在同時使用文件!而造成其他用戶修改的不成功!

vipw 修改/etc/passwd文件

vipw –s  修改/etc/shadow文件

vigr  修改/etc/groups文件

vigr –s 修改/etc/gshadow文件

[root@rhel7 ~]# man vipw
VIPW(8)                                                             System Management Commands                                                             VIPW(8)

NAME
       vipw, vigr - edit the password, group, shadow-password or shadow-group file

SYNOPSIS
       vipw [options]

       vigr [options]

DESCRIPTION
       The vipw and vigr commands edits the files /etc/passwd and /etc/group, respectively. With the -s flag, they will edit the shadow versions of those files,
       /etc/shadow and /etc/gshadow, respectively. The programs will set 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(1).

OPTIONS
       The options which apply to the vipw and vigr commands are:

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

ENVIRONMENT
       VISUAL
           Editor to be used.

       EDITOR
           Editor to be used 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.

SEE ALSO
       vi(1), group(5), gshadow(5) , passwd(5), , shadow(5).

shadow-utils 4.1.5.1                                                        05/25/2012                                                                     VIPW(8)
 Manual page vipw(8) line 15/64 (END) (press h for help or q to quit)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM