Few days I ago, I had a funny situation. Colleague of mine accidentally executed:
1 |
sudo chown -R www-data:www-data /* |
so instead for current directory ./* he changed owner for entire root file system. Sure, he tried to change back owner to the root:root , but root did not have any permissions anymore, since /bin is owned by another user.
Fortunately, this kind of mess on Linux systems we can fix very quickly using Live CD. So reboot your system and run Live CD.
Mounting a File System
First you need to mount the partition your Ubuntu installation is on. It will be something like sda1 or sda6 , if you are not sure about drive letter or partition number you can check it using GParted which is included in the Live CD. You mount partition simply by execution mount command:
1 2 |
sudo mkdir /mnt/ubuntu sudo mount /dev/sdXY /mnt/ubuntu |
Chrooting
Now you need to bind these directories to the chroot:
1 2 3 4 |
sudo mount --bind /dev /mnt/ubuntu/dev && sudo mount --bind /dev/pts /mnt/ubuntu/dev/pts && sudo mount --bind /proc /mnt/ubuntu/proc && sudo mount --bind /sys /mnt/ubuntu/sys |
And finally you can enter in using chroot:
1 |
sudo chroot /mnt/ubuntu /bin/bash |
Now you can fix whatever you want in your system, in this case I restored root as owner.
Latest posts by Mirza Pasic (see all)
- Quick tip: How to delete a tag from a Git repository? - August 20, 2016
- Laravel Accessors and Mutators - December 17, 2015
- How to allow remote connections to PostgreSQL database server - December 15, 2015