且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式将Linux缓存删除为非root用户

更新时间:2023-11-30 15:52:40

您可以创建一个辅助可执行文件(非常小心,这是危险的),任何用户都可以使用root

You can create an auxiliary executable (be very careful, it is dangerous) which any user can run it with root permissions.

这称为 setuid

出于安全考虑,您不能 setuid 一个shell脚本。

For safety reasons, you cannot setuid a shell script.

从wiki中提取如何使用它:

Extracting from the wiki how to use it:


setuid和setgid位通常用命令chmod设置
将高阶八进制数字设置为4(对于setuid)或2(对于
setgid)。 chmod 6711 file将同时设置setuid和setgid位
(2 + 4 = 6)

The setuid and setgid bits are normally set with the command chmod by setting the high-order octal digit to 4 (for setuid) or 2 (for setgid). "chmod 6711 file" will set both the setuid and setgid bits (2+4=6)



h2>

正如@rici所说,你仍然需要执行这个过程的执行权限,所以你可以从其他并保留在 group 上。因此,只有该组的成员才能执行它。

Update

As @rici noted, you still will need to have execution permission to execute this process, so you can remove execution permission from others and keep it only on group. So, only who is member of the group can execute it.