平台:CentOS 6.2
外壳:tcsh
编辑
Brian Swift 指出了一个可行的解决方案。他指出,如果主目录是通过 NFS 提供的,则root
客户端可能不具有相同的权限。以root
NFS 服务器身份登录时,文件夹会毫无问题地被删除。不过,这仍然让我有一些未解答的问题。
背景:
root
我大约两年前在同一个客户端上创建了这个文件,并尝试了以下命令。root
同一客户端上同一时间段(2010 年中)创建的所有其他文件夹均被毫无怨言地删除。
问题:
root
与主目录中其他客户端创建的文件夹相比,是什么使得该文件夹显得特别呢?- 有什么方法可以检查异常的 NFS 权限?
我再次向 Brian 表示衷心的感谢,感谢他彻底解决了这个问题,他确实是一个超级用户!
原始问题:
我不知道这里到底发生了什么……在我的主目录中root
拥有这个锁定的目录(来自手动安装)。我更改为 root( ,也尝试过)并尝试删除它并出现权限错误。我尝试更改权限,操作被拒绝。我尝试/它并在终端中收到 ioctl 错误。gcc-4.4.3
su root
su
lsattr
chattr
要清楚的是,我正在对我的主目录进行常规清理,并且我已经能够删除我想要的任何其他文件,并通过一些帮助来root
突破权限障碍等。只是这个文件夹让人感到悲伤。
这是我尝试过的......
命令:
whoami
输出
root
命令:
rm -rf gcc-4.4.3_objdir
输出
> gcc-4.4.3_objdir rm: cannot remove
> `gcc-4.4.3_objdir/config.status': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/x86_64-unknown-linux-gnu': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/intl/config.status': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/intl/config.intl': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/intl/config.cache':
> Permission denied rm: cannot remove `gcc-4.4.3_objdir/intl/Makefile':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/intl/config.log': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/intl/config.h': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/libdecnumber/decNumber.o': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/libdecnumber/gstdint.h':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/libdecnumber/config.status': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/libdecnumber/decimal128.o': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/libdecnumber/decimal32.o':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/libdecnumber/decContext.o': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/libdecnumber/bid2dpd_dpd2bid.o':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/libdecnumber/host-ieee64.o': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/libdecnumber/decimal64.o': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/libdecnumber/config.cache':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/libdecnumber/host-ieee32.o': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/libdecnumber/host-ieee128.o':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/libdecnumber/Makefile': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/libdecnumber/libdecnumber.a': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/libdecnumber/config.log':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/libdecnumber/stamp-h1': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/libdecnumber/config.h': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/build/errors.o': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/gcc/cstamp-h': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/gcc/objc': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/config.status': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/gcc/gthr-default.h': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/gcc/options.h': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/gcc/gccbug': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/gcc/ada/Makefile':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/ada/gcc-interface/Makefile': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/gcc/cs-bconfig.h': Permission
> denied rm: cannot remove `gcc-4.4.3_objdir/gcc/tmp-modes.h':
> Permission denied rm: cannot remove `gcc-4.4.3_objdir/gcc/java':
> Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/auto-host.h': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/gcc/doc': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/bconfig.h': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/.gdbinit': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/tm.h': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/objcp': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/as': Permission denied rm: cannot remove
> `gcc-4.4.3_objdir/gcc/config.cache': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/gcc/optionlist': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/gcc/configargs.h': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/s-options': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/Make-hooks': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/s-options-h': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/gcc/Makefile': Permission denied
> rm: cannot remove `gcc-4.4.3_objdir/gcc/cp': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/collect-ld': Permission denied rm:
> cannot remove `gcc-4.4.3_objdir/gcc/nm': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/gcc/config.log': Permission denied rm: cannot
> remove `gcc-4.4.3_objdir/gcc/config.h': Permission denied rm: cannot
...
命令:
ls -laFd gcc-4.4.3_objdir
输出
drwxr-xr-x. 10 root root 4096 Mar 19 2010 gcc-4.4.3_objdir/
命令:
id
输出
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:###########
命令:
chown -R root:root gcc-4.4.3_objdir
输出
chown: changing ownership of `gcc-4.4.3_objdir/gcc/build': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/cstamp-h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/objc': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/config.status': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/gthr-default.h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/options.h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/gccbug': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/ada/Makefile': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/ada/gcc-interface/Makefile': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/gcc/ada/gcc-interface': Operation not permitted
...
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/libiberty': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixopts.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/config.status': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixinc.sh': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixincl.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/mkheaders.almost': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/mkheaders': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixincl': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/server.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixlib.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixtests.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/procopen.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/full-stamp': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/Makefile': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/config.log': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/stamp-h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/config.h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes/fixfixes.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/fixincludes': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu/config.cache': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/stage_final': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/stage_current': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/Makefile': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/config.status': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/line-map.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/lex.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/identifiers.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/symtab.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/mkdeps.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/makedepend': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/pch.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/localedir.h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/directives.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/config.cache': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/makedepend.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/localedir.hs': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/traditional.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/init.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/charset.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/Makefile': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/libcpp.a': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/directives-only.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/errors.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/makedepend.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/pch.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/charset.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/line-map.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/mkdeps.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/symtab.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/files.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/directives-only.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/directives.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/expr.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/init.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/identifiers.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/lex.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/traditional.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps/macro.Po': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/.deps': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/macro.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/config.log': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/expr.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/stamp-h1': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/files.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/config.h': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp/errors.o': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/libcpp': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/stage_last': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir/config.log': Operation not permitted
chown: changing ownership of `gcc-4.4.3_objdir': Operation not permitted
命令:
stat gcc-4.4.3_objdir
输出
File: `gcc-4.4.3_objdir'
Size: 4096 Blocks: 8 IO Block: 8192 directory
Device: 1ch/28d Inode: 36835590 Links: 10
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2012-04-24 04:04:17.251456720 -0400
Modify: 2010-03-19 18:23:51.000000000 -0400
Change: 2012-04-20 12:02:38.334456000 -0400
命令:
chattr -i gcc-4.4.3_objdir
输出
chattr: Inappropriate ioctl for device while reading flags on gcc-4.4.3_objdir
命令:
lsattr gcc-4.4.3_objdir
输出
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/config.status
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/x86_64-unknown-linux-gnu
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/intl
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/libdecnumber
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/gcc
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/serdep.tmp
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/libiberty
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/zlib
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/build-x86_64-unknown-linux-gnu
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/stage_final
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/stage_current
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/Makefile
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/libcpp
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/stage_last
lsattr: Inappropriate ioctl for device While reading flags on gcc-4.4.3_objdir/config.log
答案1
如果目录来自 NFS 服务器或其他形式的 NAS,则可能有意义。根据服务器配置,客户端上的 root 可能无法删除文件,并且服务器可能不支持文件属性。
至于为什么只有这个目录有问题,我只能推测 NFS 配置(或 NFS 客户端或服务器软件)在目录创建后的某个时间以某种相关方式发生了变化。我很好奇ls -l
服务器上显示的所有权是root
、您的用户名还是nobody
。
还有一个推测,如果这个目录是通过以 root 身份解压 gcc 发行版来创建的,那么该目录可能从 tar 存档中获取了一些奇怪的所有权/权限,而不是您直接创建的目录和文件。
答案2
您是否尝试过使用自己的帐户删除该目录?
删除文件或目录时,实际上是在修改该文件的父目录(Linux 中的所有内容,甚至是目录)并且您有权限修改主目录。
另一件需要检查的事情是 SELinux,运行/usr/sbin/getenforce
,如果它显示“强制执行”,您可以尝试暂时禁用 SELinux/usr/sbin/setenforce 0
或检查 SElinux 设置ls -lZ gcc-4.4.3_objdir
并使用/sbin/restorecon -R /home/<username>/
它来更正它们。
答案3
这应该删除该文件或文件夹:
chmod -Rf 777 your_folder_or_file_name
rm -rf your_folder_or_file_name