• groups和groups username id同理


    新增一个用户到用户组后,groups和groups username显示结果不同,重启后才生效

    找到的两个回答如下:

    Because changes to group membership only take effect after starting a new login shell. Starting a new non-login interactive shell session (which is what you get when you open a new terminal) is irrelevant.

    So, when you run groups, that prints the groups your user is currently in. However, those were set up when your user first logged in and cannot be changed until you log in again. Therefore, groups doesn't include your new group.

    On the other hand, when you run groups myuser, the system doesn't look for the groups the current user belongs to at the moment, it looks up the groups that the user myuser belongs to, which it gets by reading the settings file (/etc/group, presumably). Since your user is set up to belong to the new group in /etc/groups, this command shows that as well, even though you're not currently in that group since you haven't logged in again.

    • When you run groups without an argument, it shows the groups list of the current process. Normally, the list is simply inherited from the parent process, but it is changed by login, newgrp and similar.

    • When you run groups with an argument, it shows the groups that are listed (in the user databases) for the specified user. That's the group list that login etc. will set the next time it's run for that user.

    This is why updating the user/group databases will only affect future login sessions - don't expect it to change any processes that are already running.

  • 相关阅读:
    Linux下的inode记录
    Linux中如何使用gThumb批量调整图片大小
    U盘安装Linux安装报错及解决方案
    在Mysql中如何显示所有用户?
    【转】PowerDesigner中Table视图同时显示Code和Name
    【转】正则表达式-贪婪与非贪婪匹配
    【转】程序员书籍
    Oracle 分页、取期间数据、TOP前几
    数字信封理解
    【转】C# 利用反射动态创建对象
  • 原文地址:https://www.cnblogs.com/z-books/p/14191170.html
Copyright © 2020-2023  润新知