2

In ubuntu terminal whenever I try to log in it instantly logs me out. On one account it just logs me out for no reason and on all other accounts it says

Could not chdir to home directory /home/tom: Permission denied
/bin/bash: Permission denied
Connection to 192.168.0.58 closed.

Beforehand I ran the command sudo chmod 700 / This means that I can't run any commands and am trapped on the login screen because no users have access to any files.

How do I fix this? I'm on a Raspberry PI so I can't use the GRUB recovery system. Thanks in advance, Tom

Tomsoz
  • 21

1 Answers1

4

sudo chmod 700 / is a bad idea but, should be completely(Assuming you did only and exactly that ... i.e. you did not use chmod -R nor change ownership with chown) recoverable ... A 700 permissions on / will deny other users all rights(read, write and execute) and allow only the owner(root) ... Hence the message you see and the behavior you experience because only the user root can access the system root directory / and no other user can even read that directory or anything under it.

The default permissions for the root directory / are 755:

Permissions     Owner  Group  
755(drwxr-xr-x) root   root   /

Therefore you need to boot into recovery mode, drop to a root shell(Alternatively, boot into a live USB, mount your root partition and chroot to it) then change the permissions back like so:

chmod 755 /

then reboot and try to login normally again.

If you make it and login back successfully ... You might want to check system directories permissions and compare them to another intact Ubuntu system and fix what might need fixing if there are any ... Below is the information of directories and files under / for reference:

Permissions       Owner Group Name               Linked to
777   lrwxrwxrwx  root  root  '/bin'         ->  'usr/bin'
755   drwxr-xr-x  root  root  '/boot'            
775   drwxrwxr-x  root  root  '/cdrom'           
755   drwxr-xr-x  root  root  '/dev'             
755   drwxr-xr-x  root  root  '/etc'             
755   drwxr-xr-x  root  root  '/home'            
777   lrwxrwxrwx  root  root  '/lib'         ->  'usr/lib'
777   lrwxrwxrwx  root  root  '/lib32'       ->  'usr/lib32'
777   lrwxrwxrwx  root  root  '/lib64'       ->  'usr/lib64'
777   lrwxrwxrwx  root  root  '/libx32'      ->  'usr/libx32'
700   drwx------  root  root  '/lost+found'      
755   drwxr-xr-x  root  root  '/media'           
755   drwxr-xr-x  root  root  '/mnt'             
755   drwxr-xr-x  root  root  '/opt'             
555   dr-xr-xr-x  root  root  '/proc'            
700   drwx------  root  root  '/root'            
755   drwxr-xr-x  root  root  '/run'             
777   lrwxrwxrwx  root  root  '/sbin'        ->  'usr/sbin'
755   drwxr-xr-x  root  root  '/snap'            
755   drwxr-xr-x  root  root  '/srv'             
600   -rw-------  root  root  '/swapfile'        
555   dr-xr-xr-x  root  root  '/sys'             
1777  drwxrwxrwt  root  root  '/tmp'             
755   drwxr-xr-x  root  root  '/usr'             
755   drwxr-xr-x  root  root  '/var'
Raffa
  • 32,237
  • @user535733 Thanks ... added those to the answer ... Although they should be OK if it was just chmod with no -R option passed ... "complete recovery" hopefully :-) – Raffa Jul 16 '22 at 18:27
  • I can't use the ubuntu GRUB recovery menu because I'm on a rasperry pi and they don't support GRUB. – Tomsoz Jul 16 '22 at 21:18
  • @Tomsoz Then do recovery from a live USB. – Raffa Jul 17 '22 at 07:40