rm:无法删除 - 权限被拒绝

rm:无法删除 - 权限被拒绝

有人知道为什么我无法删除这些吗?

~# find /var/lib/php5/ -xdev -depth -type f -size 0 -exec ls -al {} \; -exec lsattr {} \;  -exec rm -rf {} \;
-rwxrwxrwx 1 root root 0 Jan 23 05:20 /var/lib/php5/165498
-------------e-- /var/lib/php5/165498
rm: cannot remove ‘/var/lib/php5/165498’: Permission denied
-rwxrwxrwx 1 root root 0 Jan 23 05:20 /var/lib/php5/217306
-------------e-- /var/lib/php5/217306
rm: cannot remove ‘/var/lib/php5/217306’: Permission denied
-rwxrwxrwx 1 root root 0 Jan 23 05:20 /var/lib/php5/275922
-------------e-- /var/lib/php5/275922
rm: cannot remove ‘/var/lib/php5/275922’: Permission denied
-rwxrwxrwx 1 root root 0 Jan 23 05:20 /var/lib/php5/148947
-------------e-- /var/lib/php5/148947

看来我应该可以?

~# whoami
root

fstab 输出

~# cat /etc/fstab
LABEL=cloudimg-rootfs   /        ext4   defaults        0 0
/dev/xvdb       /mnt    auto    defaults,nobootwait,comment=cloudconfig 0       2

namei输出

~# namei -mo /var/lib/php5
f: /var/lib/php5
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x root root php5

findmnt 输出

~# findmnt
TARGET                       SOURCE                             FSTYPE     OPTIONS
/                            /dev/disk/by-label/cloudimg-rootfs ext4       rw,relatime,data=ordered
├─/sys                       sysfs                              sysfs      rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup                                              tmpfs      rw,relatime,size=4k,mode=755
│ │ └─/sys/fs/cgroup/systemd systemd                            cgroup     rw,nosuid,nodev,noexec,relatime,name=systemd
│ ├─/sys/fs/fuse/connections                                    fusectl    rw,relatime
│ ├─/sys/kernel/debug                                           debugfs    rw,relatime
│ ├─/sys/kernel/security                                        securityfs rw,relatime
│ └─/sys/fs/pstore                                              pstore     rw,relatime
├─/proc                      proc                               proc       rw,nosuid,nodev,noexec,relatime
├─/dev                       udev                               devtmpfs   rw,relatime,size=1908536k,nr_inodes=477134,mode=755
│ └─/dev/pts                 devpts                             devpts     rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
├─/run                       tmpfs                              tmpfs      rw,nosuid,noexec,relatime,size=383888k,mode=755
│ ├─/run/lock                                                   tmpfs      rw,nosuid,nodev,noexec,relatime,size=5120k
│ ├─/run/shm                                                    tmpfs      rw,nosuid,nodev,relatime
│ └─/run/user                                                   tmpfs      rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755
└─/mnt                       /dev/xvdb                          ext3       rw,relatime,data=ordered

安装输出

~# mount
/dev/xvda1 on / type ext4 (rw)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
/dev/xvdb on /mnt type ext3 (rw,_netdev)

>

编辑:回复 Dan Armstrong

linux系统

~# ls -al /usr/sbin/getenforce
ls: cannot access /usr/sbin/getenforce: No such file or directory

装甲

~# /usr/sbin/apparmor_status
apparmor module is loaded.
4 profiles are loaded.
4 profiles are in enforce mode.
   /sbin/dhclient
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/connman/scripts/dhclient-script
   /usr/sbin/tcpdump
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode.
   /sbin/dhclient (516)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.

操作系统版本

~# cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"

停止装甲

~# /etc/init.d/apparmor stop
 * Clearing AppArmor profiles cache                                                                                                                                                                                                                                                                                   [ OK ]
All profile caches have been cleared, but no profiles have been unloaded.
Unloading profiles will leave already running processes permanently
unconfined, which can lead to unexpected situations.

To set a process to complain mode, use the command line tool
'aa-complain'. To really tear down all profiles, run the init script
with the 'teardown' option."

重试 rm

~# find /var/lib/php5/ -xdev -depth -type f -size 0 -exec ls -al {} \; -exec lsattr {} \;  -exec rm -rf {} \;
-rwxrwxrwx 1 root root 0 Jan 23 05:20 /var/lib/php5/165498
-------------e-- /var/lib/php5/165498
rm: cannot remove ‘/var/lib/php5/165498’: Permission denied

答案1

我没有从您发布的内容中找到任何可以指明原因的东西。但是,它确实排除了最明显的原因。

也许值得研究一下 SELinux。

运行以下命令检查当前的执行级别:

/usr/sbin/getenforce

如果显示“强制执行”,则这可能是方程式的一部分。然后尝试使用以下命令暂时禁用 SELinux:

/usr/sbin/setenforce 0

有什么区别吗?

相关内容