zoukankan      html  css  js  c++  java
  • 关于Linux-Redhat-7.x系统不能创建纯数字用户名的原因及临时解决方法

    对于公司的Linux服务器,创建个人用户时,都是要求使用个人的编号来创建,此前一直没有遇到问题

    直到今天遇到一个员工编号是纯数字的,在使用user add xxxx 创建时报:useradd: invalid user name '5201351', 如下:

    其实想了一下,有这样的限制也是有道理的,linux系统用户的uid就是纯数字

    比如像id 之类的命令,是可以直接指定uid或者用户名的,如果是纯数字了,到底应该视为什么呢?

    不过笔者测试过,冲突了还是只显示用户名为纯数字的用户信息,总之只会显示一个用户的信息

    笔者去查询了redhat相关的文档,其中redhat 7.6 版本的Release_Notes已经说明了,如下:

    All-numeric user and group names in shadow-utils are now deprecated
    Creating user and group names consisting purely of numeric characters using the useradd and
    groupadd commands is now deprecated and will be removed from the system with the next major
    release. Such names can potentially confuse many tools that work with user and group names and user
    and group ids (which are numbers).

    也就是说,从7.6版本开始弃用创建纯数字的用户名,当然其实还是有可能临时解决的方法,如下文会提到

    但是从8版本会直接删除那种使用命令创建纯数字用户名的方式(笔者在8.1的版本中,测试过,通过改变特殊变量也不能实现了)

    后笔者在Red Hat Bugzilla – Bug 1672958 文档中也发现了此解释,如下

    The useradd and groupadd commands disallow user and group names
    consisting purely of numeric characters since Red Hat Enterprise Linux 7.6.
    The reason for not allowing such names is that this can confuse potentially
    many tools that work with user and group names and user and group ids
    (which are numbers). However due to some deployments depending on allowing all-numeric user names
    this erratum makes useradd and groupadd commands to allow all-numeric user and group names
    if environment variable SHADOW_ALLOW_ALL_NUMERIC_USER is set.
    Please note that the all-numeric user and group names are
    deprecated in Red Hat Enterprise Linux 7 and the support will be completely removed in Red Hat Enterprise Linux 8.

    +++解决方法>>>>>(适用于7.6~7.9版本):

    1、但是终究还是有方法改变这个限制的,可以使用export定义SHADOW_ALLOW_ALL_NUMERIC_USER变量的值为1,如下:

    export SHADOW_ALLOW_ALL_NUMERIC_USER=1
    useradd 123456
    useradd -u 1351 -g 2099 -G wheel,ssh-users -c "qq_5201351"  5201351

    另说明:只需要在创建用户时执行上面第一条命令的即可,临时生效,所以下次登录,会发现不会影响系统的默认策略的

      

    尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/14848730.html

    作者:一名卑微的IT民工

    出处:https://www.cnblogs.com/5201351

    本博客所有文章仅用于学习、研究和交流目的,欢迎非商业性质转载。

    博主的文章没有高度、深度和广度,只是凑字数。由于博主的水平不高,不足和错误之处在所难免,希望大家能够批评指出。

    博主是利用读书、参考、引用、抄袭、复制和粘贴等多种方式打造成自己的文章,请原谅博主成为一个卑微的IT民工!

  • 相关阅读:
    剑指office--------合并两个排序的链表
    剑指office--------栈的压入、弹出序列
    剑指office--------二叉树中和为某一值的路径
    剑指office--------翻转单词顺序列
    剑指office--------丑数
    剑指office--------机器人的运动范围
    剑指office--------二叉树的下一个结点
    数论------欧拉函数
    hdu 5831 Rikka with Parenthesis II
    hdu 5821 Ball (贪心)
  • 原文地址:https://www.cnblogs.com/5201351/p/14848730.html
Copyright © 2011-2022 走看看