作为一个实验,我试图添加一些进程tasks
并修改一些cpu.shares
.但是,如果我尝试运行类似命令,我会得到权限被拒绝
我test
在里面创建了一个文件夹/sys/fs/cgroup/cpu
$ sudo -s
$whoami
root
$ echo 2472 > tasks
-bash: tasks: Permission denied
$sudo echo 10 > cpu.shares
-bash: cpu.shares: Permission denied
另外,该文件夹的 ls 不会显示这两个文件。 (因为任务文件中没有PID??)
另外,如果我尝试删除该test
文件夹,我不能。我收到错误
rm: cannot remove 'test/cgroup.events': Operation not permitted
rm: cannot remove 'test/io.pressure': Operation not permitted
rm: cannot remove 'test/cgroup.procs': Operation not permitted
rm: cannot remove 'test/cgroup.max.descendants': Operation not permitted
rm: cannot remove 'test/cpu.stat': Operation not permitted
rm: cannot remove 'test/memory.pressure': Operation not permitted
rm: cannot remove 'test/cpu.pressure': Operation not permitted
rm: cannot remove 'test/cgroup.type': Operation not permitted
rm: cannot remove 'test/cgroup.stat': Operation not permitted
rm: cannot remove 'test/cgroup.threads': Operation not permitted
rm: cannot remove 'test/cgroup.kill': Operation not permitted
rm: cannot remove 'test/cgroup.freeze': Operation not permitted
rm: cannot remove 'test/cgroup.controllers': Operation not permitted
rm: cannot remove 'test/cgroup.subtree_control': Operation not permitted
rm: cannot remove 'test/cgroup.max.depth': Operation not permitted
但为什么我无法编辑这些文件或删除这个创建的文件夹?我尝试以 root 用户身份运行命令
操作系统:Ubuntu 22.04.1
我还可以看到group.controllers.....这与cgroupv2有关吗?
更新 cgroupv2 使用cgroup.procs
cpu.max
和cpuset.cpus
。这些文件是可编辑的。似乎每当我尝试cpu.shares
在此文件夹中创建新文件(例如)时,权限都会被拒绝。粘位??
答案1
您是否尝试过rm
使用-rf
标志 ( rm -rf test
) 进行传递?如果这不起作用,也许rmdir test
会起作用。