码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Linux基础命令[19]-id


    文章目录

      • 1. id 命令说明
      • 2. id 命令语法
      • 3. id 命令示例
        • 3.1 不加参数
        • 3.2 -u/-g/-G(用户、组、所属组)
        • 3.3 -gr/-Gr/-ur(有效ID)
      • 4. 总结

    1. id 命令说明

    id:显示真实有效的用户ID(UID)和组ID(GID),十分方便,不用再查找 /etc/groop(里面有全部用户的信息)。基本信息如下:

    Usage: id [OPTION]... [USERNAME]
    Print user and group information for the specified USERNAME,
    or (when USERNAME omitted) for the current user.
    
      -a              ignore, for compatibility with other versions
      -Z, --context   print only the security context of the current user
      -g, --group     print only the effective group ID
      -G, --groups    print all group IDs
      -n, --name      print a name instead of a number, for -ugG
      -r, --real      print the real ID instead of the effective ID, with -ugG
      -u, --user      print only the effective user ID
          --help     display this help and exit
          --version  output version information and exit
    
    Without any OPTION, print some useful set of identified information.
    
    Report id bugs to bug-coreutils@gnu.org
    GNU coreutils home page: 
    General help using GNU software: 
    For complete documentation, run: info coreutils 'id invocation'
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    参数如下:

    选项作用
    -a忽略该命令,仅为了与其他版本兼容
    -Z仅显示当前用户的安全内容
    -g显示用户所属群组的ID
    -G显示用户所属所有群组,包括附加群组的ID
    -n显示用户,所属群组或附加群组的名称
    -r显示实际的ID
    -u显示当前用户ID

    2. id 命令语法

    id [OPTION]... [USERNAME]
    
    • 1

    3. id 命令示例

    3.1 不加参数

    不加用户名时,显示当前用户的信息,包括 uid gid groups

    id
    
    • 1

    加用户名时,显示的是该用户的 uid gid groups

    id admin
    
    • 1

    在这里插入图片描述

    3.2 -u/-g/-G(用户、组、所属组)

    这三个参数配合 -n 使用时,会显示名称,也可以指定用户

    id -u
    
    • 1
    id -un
    
    • 1
    id -un admin
    
    • 1

    在这里插入图片描述

    3.3 -gr/-Gr/-ur(有效ID)

    [root ~]$ id -gr
    1101
    [root ~]$ id -Gr
    1101
    [root ~]$ id -ur
    1101
    [root ~]$ id -ur admin
    200
    [root ~]$ id -Gr admin
    200 10
    [root ~]$ id -gr admin
    200
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    在这里插入图片描述

    4. 总结

    id:用于显示当前或指定用户的 UID GID。

  • 相关阅读:
    下一代 CI/CD:利用 Tekton 和 ArgoCD 实现云原生自动化
    JAVA毕业设计飞机航班信息查询系统计算机源码+lw文档+系统+调试部署+数据库
    HTB Runner
    【面试题】JSON.stringify()妙用,你真的知道吗?
    【Android】-- 四种布局方式(线性布局、相对布局、网格布局、和滚动视图)
    ATX结合Maxim实现多设备并行执行压力测试(AUI自动化测试框架)
    oracle存储过程记录
    IOday5
    2023年浙江工业大学MPA提前批招生通知
    Spring中过滤器(Filter)和拦截器(Interceptor)的区别和联系
  • 原文地址:https://blog.csdn.net/JustDI0209/article/details/136742005
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号