Linux command
polkit 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List all registered polkit actions
pkaction
Show details for a specific action
pkaction --verbose --action-id [org.freedesktop.login1.reboot]
Check if a process is authorized for an action
pkcheck --action-id [org.freedesktop.login1.reboot] --process [pid]
Execute a command as another user
pkexec [command]
Execute a command as a specific user
pkexec --user [username] [command]
说明
polkit (PolicyKit) is an authorization framework that allows non-privileged processes to communicate with privileged ones. It provides fine-grained control over system-wide privileges, enabling desktop applications to perform administrative tasks with proper user authorization. Unlike sudo which grants full root access, polkit defines specific actions (like mounting disks or changing network settings) and policies controlling who can perform them. The framework consists of pkexec (execute privileged commands), pkaction (list/inspect actions), and pkcheck (check authorization). The polkitd daemon runs with minimal privileges and communicates over the system message bus.
参数
- pkexec
- Execute a command as another user with polkit authorization. Defaults to root if no user specified.
- pkaction
- List or inspect registered polkit actions and their default policies.
- pkcheck
- Check whether a process or system bus name is authorized for a given action.
- polkitd
- The polkit system daemon that manages authorization decisions. Runs as the polkitd system user.
FAQ
What is the polkit command used for?
polkit (PolicyKit) is an authorization framework that allows non-privileged processes to communicate with privileged ones. It provides fine-grained control over system-wide privileges, enabling desktop applications to perform administrative tasks with proper user authorization. Unlike sudo which grants full root access, polkit defines specific actions (like mounting disks or changing network settings) and policies controlling who can perform them. The framework consists of pkexec (execute privileged commands), pkaction (list/inspect actions), and pkcheck (check authorization). The polkitd daemon runs with minimal privileges and communicates over the system message bus.
How do I run a basic polkit example?
Run `pkaction` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does pkexec do in polkit?
Execute a command as another user with polkit authorization. Defaults to root if no user specified.