3

I changed the permission of /home folder to 777 and now I cannot access my account and login only as a guest (Ubuntu 14.04) with no sudo support.

Permission in home folder is as follows:

drwxr-xr-x 134 root root 12288 Dec 14 11:47 etc
d---------   4 root root  4096 Dec 14 09:50 home
drwxr-xr-x  24 root root  4096 Dec 11 23:04 lib
drwxr-xr-x   2 root root  4096 Dec  4 18:05 lib32
drwxr-xr-x   2 root root  4096 Dec  4 18:05 lib64
drwx------   2 root root 16384 Nov 30 23:42 lost+found

I will appreciate if there is a fix other than reinstall.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
Raj
  • 31
  • sorry, to clarify the permission of home directory shows up as : d--------- 4 root root 4096 Dec 14 09:50 home – Raj Dec 14 '14 at 19:14
  • If PolicyKit is installed, try pkexec chmod 755 /home, I'm not sure, but let's see if it do the trick. – Lety Dec 14 '14 at 20:28
  • Try this it is about a different problem, but you can found how to enter into GRUB and get root privilege, so you could change /home permission with chmod 755 /home. – Lety Dec 14 '14 at 20:41

2 Answers2

7

You must boot into recovery mode:

a- Switch on your computer.

b- Quickly press and hold the Shift key, which will bring up the GNU GRUB menu.

c- Select the line which starts with ---- Advanced options.

d- Select the line ending with ----- recovery mode,something like:

Ubuntu GNU/Linux, with Linux 3.16.0-28-generic (recovery mode)

e- Your PC should display a menu with a number of options.

f- Select the line with ---- Drop to root shell prompt.

g- You start in a terminal as root with the root partition mounted read-only.

Run it:

mount -o remount,rw /
mount --all
chmod 755 /home
chmod -Rf 700 /home/raj
chown -R raj /home/raj
reboot
kyodake
  • 15,401
  • Alternatively you can press Ctrl+Alt+F3 and run the same commands (excluding the mount commands) as sudo. Thanks for this answer btw, helped me out after I totally stuffed my home dir permissions :P – Clonkex May 03 '17 at 02:04
0

You want your /home permissions the same as /etc or /lib... I don't know the chmod numbers but these should do it:

sudo chmod a+rx /home
sudo chmod u+w /home

If you recursively changed all the folders in /home then you'll have some recursive (-R) chmod'ing to do, and is your user still the owner of his own home? If not, use chown (probably sudo chown unless you're root at the time) and change back to the the rightful owner.

Xen2050
  • 8,705
  • I can only login as a guest which does not support sudo command! – Raj Dec 14 '14 at 19:59
  • now root own home and I as a guest I cannot see what is inside home! – Raj Dec 14 '14 at 20:00
  • 1
    chmod can't change the owner, that must've happened before. ProTip: You can change the owner with chown – Xen2050 Dec 14 '14 at 20:05
  • that also requires sudo access which guest account does not allow. – Raj Dec 14 '14 at 20:10
  • since /home is now owned by root and I have setup root pw I cannot access /home. Is there a way to set root pw while loged on as a guest (with no sudo access)? – Raj Dec 14 '14 at 20:14
  • sorry, I have NOT setup root password! – Raj Dec 14 '14 at 20:15
  • hmmm, no sudo isn't good... a live cd/usb could log in and change any files (just like root would) and sudo should work while running from the live cd. But permanently fixing sudo may be troublesome later. OR there is some sort of "safe mode" or "single user mode" you might be able to boot into now and become root, but I'm not very familiar with that. – Xen2050 Dec 14 '14 at 20:21
  • you could chroot into it from another installation or livecd enviroment – Νίκος Φυτίλης Dec 14 '14 at 20:36
  • Good idea, can you please let me know full chroot command and do you know if needs root pw? – Raj Dec 14 '14 at 21:08
  • chroot wouldn't be needed just to change permissions & owners – Xen2050 Dec 15 '14 at 05:13