首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Linux 小知识 丨id sudo 命令

Linux 小知识 丨id sudo 命令

作者头像
玖柒的小窝
修改2021-11-08 14:02:06
修改2021-11-08 14:02:06
1.8K00
代码可运行
举报
文章被收录于专栏:各类技术文章~各类技术文章~
运行总次数:0
代码可运行

Linux 小知识 丨id sudo 命令

id 命令

查看当前用户的详细信息(用户id, 群组id, 所属组)

代码语言:javascript
代码运行次数:0
运行
复制
id [-g][--help][--version][用户名称]

[root@VM-8-10-centos ~]# id root
uid=0(root) gid=0(root) groups=0(root)

[root@VM-8-10-centos ~]# id user1
uid=1002(user1) gid=1002(user1) groups=1002(user1),1004(devgroup) 
复制代码

常用参数选项

  • -g, --group 显示用户所属群组的ID
  • -G, --groups 显示用户所属附加群组的ID
  • -n, --name 显示用户,所属群组或附加群组的名称
  • -r, --real 显示实际ID
  • -u, --user 显示用户ID
  • --help 显示帮助
  • --version 显示版本信息

sudo 命令

提高普通用户的操作权限

代码语言:javascript
代码运行次数:0
运行
复制
sudu [参数选项]
[root@VM-8-10-centos ~]# sudo --help
Options:
  -A, --askpass                 use a helper program for password prompting
  -b, --background              run command in the background
  -B, --bell                    ring bell when prompting
  -C, --close-from=num          close all file descriptors >= num
  -E, --preserve-env            preserve user environment when running command
      --preserve-env=list       preserve specific environment variables
  -e, --edit                    edit files instead of running a command
  -g, --group=group             run command as the specified group name or ID
  -H, --set-home                # 将环境变量中的HOME指定为要变更身份的使用者HOME目录
  -h, --help                    display help message and exit
  -h, --host=host               # 会显示版本编号和指令的使用方式说明
  -i, --login                   run login shell as the target user; a command may also be
                                specified
  -K, --remove-timestamp        remove timestamp file completely
  -k, --reset-timestamp         # 下一次执行sudo时询问密码
  -l, --list                    list user's privileges or check a specific command; use
                                twice for longer format
  -n, --non-interactive         non-interactive mode, no prompts are used
  -P, --preserve-groups         preserve group vector instead of setting to target's
  -p, --prompt=prompt           use the specified password prompt
  -r, --role=role               create SELinux security context with specified role
  -S, --stdin                   read password from standard input
  -s, --shell                   # 执行环境变量中的SHELL所指定的shell或是 /etc/passwd里所指定的shell
  -t, --type=type               create SELinux security context with specified type
  -T, --command-timeout=timeout terminate command after the specified time limit
  -U, --other-user=user         in list mode, display privileges for user
  -u, --user=user               run command (or edit file) as specified user name or ID
  -V, --version                 # 显示版本号
  -v, --validate                # 超出N分钟没有使用,要求再次输入密码(默认5分钟)
# sudo command 要以系统管理者身份(或以-u更改为其他人)执行的指令     

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Linux 小知识 丨id sudo 命令
    • id 命令
      • 常用参数选项
    • sudo 命令
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档