我正在使用Debian 6,所有补丁,但是当我尝试以root身份访问crontab时,我只是得到一个权限被拒绝:
root@server:~# crontab -e -bash: /usr/bin/crontab: Permission denied
请注意,这不是一个用户,而是作为根 。
我甚至没有模糊的线索,如果根无权访问crontab,如何解决这个问题。
有任何想法吗?
编辑:答案是正确的
a)是的,有恶作剧(至less这是我的怀疑)
b)我在crontab上的权限是棘手的:
root@server:~# ls -lha /usr/bin/crontab ---------- 1 root crontab 30K Dec 19 2010 /usr/bin/crontab
所以尝试chmod的答案:
root@server:~# chmod 2755 /usr/bin/crontab chmod: changing permissions of '/usr/bin/crontab': Operation not permitted`
并重新安装包装:
root@server:~# apt-get install --reinstall cron Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded. Need to get 93.2 kB of archives. After this operation, 0 B of additional disk space will be used. Get:1 http://ftp.debian.org/debian/ squeeze/main cron i386 3.0pl1-116 [93.2 kB] Fetched 93.2 kB in 0s (164 kB/s) (Reading database ... 86601 files and directories currently installed.) Preparing to replace cron 3.0pl1-116 (using .../cron_3.0pl1-116_i386.deb) ... Stopping periodic command scheduler: cron. Unpacking replacement cron ... dpkg: error processing /var/cache/apt/archives/cron_3.0pl1-116_i386.deb (--unpack): unable to make backup link of `./usr/bin/crontab' before installing new version: Operation not permitted configured to not write apport reports chown: changing ownership of `root': Operation not permitted chmod: changing permissions of `root': Operation not permitted Starting periodic command scheduler: cron. Processing triggers for man-db ... Errors were encountered while processing: /var/cache/apt/archives/cron_3.0pl1-116_i386.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
现在是否需要完全重新安装系统才能恢复运行?
编辑:这不是一个重复的问题 – 我有一个妥协的服务器的怀疑,但我不打算压扁现场服务器,并重build它没有证据。
我原来的问题是关于作为root用户被拒绝的权限,因为我确信这是不可能的,我可以向你保证,我确实是首先寻找这个问题。
感谢这里的帮助人员,我现在更了解这个权限,如果这个人遇到了这个问题,他们也将能够缩小发生的事情。
好的,你已经有了答案的一部分,在/ usr / bin / crontab上find了权限。
现在chmod说它不能修改这些权限。 尝试使用lsattr /usr/bin/crontab检查文件属性是否与之混淆,如果确实是问题,则使用chattr -i /usr/bin/crontab来修复它。
如果这是犯规,那么我的猜测是有人试图阻止你find并修复crontab数据文件中的某些东西。 这些通常在/ var / spool / cron / crontabs /中。 如果有更多的权限或文件属性阻止你的path,我不会感到惊讶,但你想进入和审核这些文件聪明。 您可能还想要查找具有奇怪的文件属性(特别是不可变的位)的其他文件。
我相信可以让系统重新运行起来,但很难说要做多less事情,这取决于已经做了多less恶作剧。 也可能你永远不会知道你是否真的完成了所有的恶作剧。 完全重新安装或恢复备份可能是一个好主意。
我注意到,在一个最新的(如那些日子,使用LTS)debian 6系统我有方便,我的/ usr / bin / crontab是35k,不是30k的大小。 所以考虑这个文件的内容可疑,不要运行它。 取一个副本,然后从分发版本中replace它。
Bash告诉你,你没有对/ usr / bin / crontab二进制文件的执行权限。
它应该匹配以下权限
# ls -la /usr/bin/crontab -rwxr-sr-x 1 root crontab 35880 Jul 4 2012 /usr/bin/crontab
你可以通过以root身份运行来解决这个问题
chmod 2755 /usr/bin/crontab
或者你可以运行以下命令强制完成cron的重新安装
apt-get install --reinstall cron
尝试chmod 0755 /usr/bin/crontab ,然后再次执行crontab二进制文件。 也许某人或某事已经改变了可执行文件本身的权限。
编辑:更新后,似乎你的根文件系统由于某种原因已经只读。 无论如何,这是我的猜测。 原因可能是
dmesg输出。 ro标志,则可以从/etc/fstab查看。