Centos下添加用户组

近日,从新整理了下开发环境,重装了,nginx,可是这个时候倒是报错了,报错信息以下:php

[root@hserver1 php-7.0.5]# nginx -t
nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed

  

喏,很明显了,缺乏用户组信息,至于为何会缺乏呢?暂时不清楚,若是有知道缘由的请评论区留言,万分感谢。nginx

好了,既然缺乏用户组,那么咱们确定是要建立一个用户组信息了:bash

建立用户组;spa

[root@hserver1 php-7.0.5]# groupadd -f nginx
groupadd: cannot open /etc/group

  嗯?打不开?没权限?经过用lsattr命令查看/etc/group的隐藏权限设定状况发现以下:code

[root@hserver1 php-7.0.5]# lsattr /etc/group
----i----------- /etc/group

   i 说明设定文件不能被删除、更名、设定连接关系,同时不能写入或新增内容。 用  chattr 命令对  /etc/group  去除 i 权限位。那怎么办呢?server

用 chattr 命令对 /etc/group 去除 i权限位:blog

[root@hserver1 php-7.0.5]# chattr -i /etc/group
[root@hserver1 php-7.0.5]# lsattr /etc/group
---------------- /etc/group

  去除了 i ,咱们再次添加:开发

[root@hserver1 php-7.0.5]# groupadd -f nginx
groupadd: cannot open /etc/gshadow

  似曾相识的一幕,好吧,重复上面的步骤,去除隐式权限 i位。因为后面还有多种相似的状况,如今咱们就直接写出全部余下的去除 i 位步骤吧。get

[root@hserver1 php-7.0.5]# chattr -i /etc/gshadow
[root@hserver1 php-7.0.5]# chattr -i /etc/passwd
[root@hserver1 php-7.0.5]# chattr -i /etc/shadow

  最终,咱们建立用户组以下:io

[root@hserver1 php-7.0.5]# groupadd -f nginx
[root@hserver1 php-7.0.5]# useradd -g nginx nginx

  OK,这下总算是成功了。

相关文章
相关标签/搜索