gpt4 book ai didi

Linux程序权限: How to change a program to be executable by all users?

转载 作者:太空宇宙 更新时间:2023-11-04 04:25:05 25 4
gpt4 key购买 nike

我编写了一个Python程序,需要调用aircrack程序来执行某些任务,但我遇到了权限问题。最初,aircrack 程序是在命令行中调用的,它需要以“sudo”开头。之后我检查了可执行文件的位置,发现它位于/usr/sbin/下。 。现在我的程序是由apache驱动的,默认用户是www-data。如果我使用用户 www-data 而不使用“sudo”执行程序,它将不会给出任何结果。

我在谷歌上搜索了一下这个问题,发现我们可以通过执行sudo chmod 4755 /usr/sbin/airodump-ng来更改aircrack程序的所有者。 。我试了一下,权限从-rwxr-xr-x改成了至-rwsr-xr-x 。我在没有“sudo”的情况下再次执行了该命令,但没有任何区别。

我的问题是:如何更改程序的权限,以便任何用户无需“sudo”即可执行该程序?如果我使用“sudo”运行程序,则输出文件归“root”所有,这会增加程序的复杂性。请帮忙,谢谢。

最佳答案

首先,我们没有人可以替换 chmod 手册页(所以我将首先引用它):

   A numeric mode is from one to four octal digits (0-7), derived by adding up the bits 
with values 4, 2, and 1. Omitted digits are assumed to be leading zeros. The first
digit selects the set user ID (4) and set group ID (2) and restricted deletion or
sticky (1) attributes. The second digit selects permissions for the user who owns the
file: read (4), write (2), and execute (1); the third selects permissions for other
users in the file's group, with the same values; and the fourth for other users not
in the file's group, with the same values.

因此,如果您希望所有用户都可以执行该程序,请“chmod 111 文件”。但是,iirc 对于大多数事情,您也需​​要读取权限,因此“chmod 555 文件”。另外,我之所以将这些部分做得相同是因为你说你希望“每个人”都能做一些事情。

关于Linux程序权限: How to change a program to be executable by all users?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9776332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com