chmod -R 000 /binから回復するには?

chmod -R 000 /binから回復するには?

今は変更することも、他のシステムプログラムを使用することもできません。幸いなことに、これは私がプレイしている仮想マシンにあります。しかし、この問題を解決する方法はありますか?システムは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

その後、コンピュータが停止します。

ベストアンサー1

同様に、許可ビットが設定されていないとファイルを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

実行可能ファイルのアーキテクチャと一致するものを使用してくださいchmod。私x86_64

sudo /lib/x86_64-linux-gnu/ld-2.27.so /bin/chmod 755 /bin /bin/chmod

/usr/binまたは、chmod次のことを行うには、別の場所に電話してくださいperl

sudo perl -e 'chmod 0755, "/bin", "/bin/chmod"

権限を復元するときは注意してください。一部のファイルには/bin0755以外の権限がある場合があります。mountsu

ただし、再起動すると、機能しているperlポイントまで到達できなくなる可能性がありますld.so。しかし、問題を解決することができますinitramfs(initramfsから回復シェルを取得するために間違ったルートディレクトリを渡します。ルートファイルシステムをマウントした後(読み取り専用)initramfsにシェルを提供させるには、Debianのカーネル引数も参照してくださいbreak=bottombreak=init。 Live CDイメージからVMを起動するか、他の人が提案したようにホストにVMファイルシステムをマウントして問題を解決します。

initramfsを修正する方法:

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                                 
                                                                         

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

起動後、他のシステムと比較して755権限を持たないファイルの権限を変更します。

以下を実行して修正してくださいpythoninit

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                                 

次に、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

再起動後、他のシステムと比較して755権限のないファイルの権限を変更します。

おすすめ記事