Unable to SU with root: `/bin/bash: permission denied`
Change the permission of these folders like this and now you can su to another user.
chmod 755 /
chmod 755 /bin
chmod 755 /lib
-
Check the permissions of
/bin
folder# ls -ld /bin drwxr-xr-x 2 root root 4096 May 27 21:39 /bin
-
Check the permissions of all shells available
# ls -l /bin/*sh -rwxr-xr-x 1 root root 1037464 Sep 1 2015 /bin/bash -rwxr-xr-x 1 root root 154072 Feb 17 21:25 /bin/dash lrwxrwxrwx 1 root root 4 Sep 1 2015 /bin/rbash -> bash lrwxrwxrwx 1 root root 4 Feb 17 21:25 /bin/sh -> dash lrwxrwxrwx 1 root root 7 Aug 19 2015 /bin/static-sh -> busybox
Some are links that we should check their targets
# ls -lL /bin/*sh -rwxr-xr-x 1 root root 1037464 Sep 1 2015 /bin/bash -rwxr-xr-x 1 root root 154072 Feb 17 21:25 /bin/dash -rwxr-xr-x 1 root root 1037464 Sep 1 2015 /bin/rbash -rwxr-xr-x 1 root root 154072 Feb 17 21:25 /bin/sh -rwxr-xr-x 1 root root 1964536 Aug 19 2015 /bin/static-sh
-
Try another shell
The best is
busybox
because it is a static build (No .so library needed)su newuser -s /bin/static-sh
Next is
dash
, low dependencies and installed by defaultsu newuser -s /bin/dash
-
Check permissions of libraries and their parent folders, you can get list using
ldd
# ldd /bin/bash linux-vdso.so.1 => (0x00007ffdefb5a000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f714bbbd000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f714b9b9000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f714b5ef000) /lib64/ld-linux-x86-64.so.2 (0x000055c6bc494000) # ls -ld /lib /lib/x86_64-linux-gnu /lib64 drwxr-xr-x 26 root root 4096 May 15 07:41 /lib drwxr-xr-x 2 root root 4096 May 14 15:52 /lib64 drwxr-xr-x 3 root root 16384 May 27 21:39 /lib/x86_64-linux-gnu # ls -l /lib/x86_64-linux-gnu/libtinfo.so.5 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libc.so.6 /lib64/ld-linux-x86-64.so.2 lrwxrwxrwx 1 root root 32 Apr 14 23:16 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.23.so lrwxrwxrwx 1 root root 12 Apr 14 23:16 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.23.so lrwxrwxrwx 1 root root 13 Apr 14 23:16 /lib/x86_64-linux-gnu/libdl.so.2 -> libdl-2.23.so lrwxrwxrwx 1 root root 15 Feb 19 09:23 /lib/x86_64-linux-gnu/libtinfo.so.5 -> libtinfo.so.5.9
They are just links we need to verify the target files
# ls -lH /lib/x86_64-linux-gnu/libtinfo.so.5 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libc.so.6 /lib64/ld-linux-x86-64.so.2 ##or # ls -lL /lib/x86_64-linux-gnu/libtinfo.so.5 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libc.so.6 /lib64/ld-linux-x86-64.so.2 -rwxr-xr-x 1 root root 162632 Apr 14 23:16 /lib64/ld-linux-x86-64.so.2 -rwxr-xr-x 1 root root 1864888 Apr 14 23:16 /lib/x86_64-linux-gnu/libc.so.6 -rw-r--r-- 1 root root 14608 Apr 14 23:16 /lib/x86_64-linux-gnu/libdl.so.2 -rw-r--r-- 1 root root 167240 Feb 19 09:23 /lib/x86_64-linux-gnu/libtinfo.so.5