jet*_*ett 41 permissions chmod executable system-recovery
现在我无法 chmod 它回来.. 或使用我的任何其他系统程序。幸运的是,这是在我一直在玩弄的虚拟机上,但是有什么办法可以解决这个问题吗?系统为 Ubuntu Server 12.10。
我试图重新启动到恢复模式,不幸的是,由于在 init-bottom 可用性运行后权限未授予某些程序,我现在根本无法启动到系统中 - 系统只是挂起。这是我看到的:
Begin: Running /scripts/init-bottom ... done
[ 37.062059] init: Failed to spawn friendly-recovery pre-start process: unable to execute: Permission denied
[ 37.084744] init: Failed to spawn friendly-recovery post-stop process: unable to execute: Permission denied
[ 37.101333] init: plymouth main process (220) killed by ABRT signal
Run Code Online (Sandbox Code Playgroud)
在此之后,计算机挂起。
Sté*_*las 72
即便如此root
,您也无法执行没有x
设置权限位的文件。您可以做的是调用ld.so
它(前提是它们是动态链接的可执行文件):
$ echo /lib/*/ld*.so
/lib/i386-linux-gnu/ld-2.27.so /lib/x86_64-linux-gnu/ld-2.27.so
Run Code Online (Sandbox Code Playgroud)
使用与chmod
可执行文件体系结构匹配的那个。在我的情况下x86_64
:
sudo /lib/x86_64-linux-gnu/ld-2.27.so /bin/chmod 755 /bin /bin/chmod
Run Code Online (Sandbox Code Playgroud)
或者在/usr/bin
或其他地方调用一些东西来做chmod
类似的事情perl
:
sudo perl -e 'chmod 0755, "/bin", "/bin/chmod"
Run Code Online (Sandbox Code Playgroud)
在恢复某些文件的权限时要小心,这些文件/bin
类似于mount
或su
打算具有 0755 以外的权限。
如果您已经重新启动,但是,您可能不能够去那里,你可以运行点perl
或ld.so
虽然。您可以通过以下方式修复问题initramfs
(通过不正确的根目录以获取 initramfs 中的恢复 shell;另请参阅Debian 上的break=bottom
orbreak=init
内核参数,以便 initramfs 在挂载根文件系统后为您提供一个 shell(只读)尽管))。或者从 Live CD 映像启动您的 VM,或者按照其他人的建议通过在主机上安装 VM 文件系统来修复。
在 中grub
,编辑引导条目并root=
从linux
命令中删除参数:
setparams 'Ubuntu, with Linux 3.2.0-27-generic'
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod ext2
set root='(hd1)'
search --no-floppy --fs-uuid --set=root dc02b07c-88ef-4804-afe0-4f02db2\
94561
linux /boot/vmlinuz-3.2.0-27-generic
initrd /boot/initrd.img-3.2.0-27-generic
Run Code Online (Sandbox Code Playgroud)
Ctrl-X启动。Ubuntu 的 initramfs 找不到根文件系统,所以开始恢复sh
。然后挂载根文件系统(在我的情况下/dev/vdb
,适应您的机器)并在那里修复:
Target filesystem doesn't have requested /sbin/init.
No init found. Try passing init= bootarg.
BusyBox v1.18.5 (Ubuntu 1:1.18.5-1ubuntu4) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs) mkdir /x
(initramfs) mount /dev/vdb /x
[ 48.430071] EXT3-fs (vdb): error: couldn't mount because of unsupported optio
nal features (240)
[ 48.477406] EXT4-fs (vdb): recovery complete
[ 48.477747] EXT4-fs (vdb): mounted filesystem with ordered data mode. Opts: (
null)
(initramfs) chmod -R 755 /x/bin
(initramfs) umount /x
(initramfs) reboot
Run Code Online (Sandbox Code Playgroud)
启动后,通过与另一个系统进行比较来修复不具有 755 权限的文件的权限。
python
为init
:在 中grub
,编辑引导项,这次保留root=
参数,更改ro
为rw
并添加init=/usr/bin/python
:
setparams 'Ubuntu, with Linux 3.2.0-27-generic'
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod ext2
set root='(hd1)'
search --no-floppy --fs-uuid --set=root dc02b07c-88ef-4804-afe0-4f02db2\
94561
linux /boot/vmlinuz-3.2.0-27-generic root=UUID=dc02b07c-88ef-4804-afe0-\
4f02db294561 rw init=/usr/bin/python
initrd /boot/initrd.img-3.2.0-27-generic
Run Code Online (Sandbox Code Playgroud)
然后,在 python 提示符下:
Begin: Running /scripts/init-bottom ... done.
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chmod('/bin/sh',0755)
>>> os.chmod('/bin/chmod',0755)
>>> os.execl('/bin/sh','sh')
sh: 0: can't access tty; job control turned off
# chmod -R 0755 /bin
# mount -o remount,ro /
[ 100.704720] EXT4-fs (vdb): re-mounted. Opts: errors=remount-ro
# exec /sbin/init
Run Code Online (Sandbox Code Playgroud)
同样,一旦启动,通过与另一个系统进行比较来修复不具有 755 权限的文件的权限。
使用蟒蛇:)
$ python
>>> import os
>>> os.chmod('/bin', 0755)
Run Code Online (Sandbox Code Playgroud)
这不应该需要任何东西/bin
来完成它的工作。显然,我还没有尝试过这个......
归档时间: |
|
查看次数: |
19290 次 |
最近记录: |