Saturday, 29 October 2011

chmod problem , sudo broken ,how to recover

  when i was learning about linux commands , without knowing the consequences of the command 

  sudo chmod -777 /

i executed it.It was the last command i executed with sudo.As each system  file has their own configured file access permissions, executing the above command broke all those default permissions and also broke the sudo.I was not able to access the sudo command after that.So please dont try the above command.If you the person who has already been in the trap please insert a live cd and try the following code,


echo "What is your ubuntu partition? (/dev/sd??)"
read -p"/dev/sd" deviceID

mkdir /media/temp4567
sudo mount /dev/sd$deviceID /media/temp4567

find /etc -maxdepth 20 | while read filename; do
    if [ -a "/media/temp4567/$filename" ]; then
        curPerm=$(stat --format=%a $filename)
    sudo chmod $curPerm "/media/temp4567/$filename"

thanks to my friend mike for this code.I recovered from chmod problem by using  the code.try this!!

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...