Reset permission to /usr/bin


I misstyped:

chmod 0754 /usr/bin

instead of over a command under /usr/bin. Now I can’t run anything under /usr/bin, specially the chmod command to restore permission. Also osmc comes with root disabled, so, the ‘su’ command is algo not posible.

How can I restore permission to /usr/bin folder? or, at least to /usr/bin/chmod to made it executable by osmc user?

I tried to add the line:

chmod 04755 /usr/bin

in the /etc/rc.local editing that file in the SD-Card, but I had no luck, permission is not changed.

Any ideas how can this be accomplished?


You could try:

sudo -i

to get a root shell, but I doubt that that will work.

If you have another system running linux the easy fix would be to put the SD card in that system and fix it there. If you don’t, get a live CD of a linux distribution and boot your PC using that to fix it.


“sudo” is located under /usr/bin, so that can’t be run


Change cmdline.txt.
Add init=bin/bash at the end
Boot the Pi, mount mmcblk0p2 and run your chown command.
Unmount, edit cmdline back and boot.


That should (almost) have worked, as long as the rc-local service had been enabled. However, the correct line should have been either:

/usr/bin/chmod 755 /usr/bin


/usr/bin/chmod o+x /usr/bin

I’m a bit mystified how you managed to edit /etc/rc.local without having sudo. If you pulled the SD card and edited the file on another computer, was it a Linux system?

1 Like

It’s not possible.


Well, his wording could have suggested that he’d pulled the card, which is why I asked. And if he can edit a file on an ext4 file system, he’s probably using *nix…

1 Like

currently, I don’t have another linux, I used the driver ext2fsd that allows to edit linux partitions from windows. It Can’t asign permissions to files, but allows me to change file contents.

I will try dillthedog’s sugestion first, and Sam,s one if I dont have success.

Many Thanks to all for your fast support.



root=/dev/mmcblk0p2 rootfstype=ext4 rootwait quiet osmcdev=rbp2 init=/bin/bash

but the pi does not boot with that cmdline.txt


I still think that a simple live CD of linux would be the quickest fix for you. Or you could just re-install.

In the future, do not run commands from a shell unless you fully understand what you are doing.

I’m really curious, why did you even try to change permissions on /usr/bin? You should never need to do that.


Try init=/bin/sh


I wanted to install and config a data transfer utility under that directory, sadly my fingers were faster than my mind so the entire directory permission were changed and I lose access to sudo and anything in /usr/bin.

Currently I have access to the Pi with osmc user through a remote with ssh (useless without sudo) and can write file contents in the SD card linux partition.

I know that security is a top concern, but I having a very bad time trying to find a “hook” in osmc that allows me run a simple command as root to fix the permissions. This should not be so difficult since I have write access to the root partition.

Modifing /etc/rc.local would be the fastest and simple way for me, but my last attempt with

/bin/chmod 4775 /usr/bin
exit 0

didn’t make any change.

I don´t find any advantage on changing my SD card from a linux system over doing it from a windows machine with ext2fs.


On a linux machine you simple could correct the permission on the directory and you would be done.
As you wrote ext2fsd doesn’t allow you to do that.


Since you edited rc.local on a Windows machine, you’ll have added CR/LF at the end of the line. This will cause the script to fail in Linux. Off the top of my head, I can’t think how you can fix things from a Windows machine, unless you can hex edit the file to remove the x’0D’ character(s). (That probably also explains why editing cmdline.txt also failed.)

Apologies for specifying /usr/bin/chmod. That’s where it is on Fedora and I clearly checked in the wrong window. On Debian it is, as you correctly identified, at /bin/chmod.

Nevertheless, you don’t need setuid or group write on /usr/bin, so the correct permission should be 755, not 4775.


The advantage would be that you would have already had your problem fixed.

1 Like

thanks for your effort in explaining why my windows edition path was failing. It was a good idea if it really means to spend less work and time.

I didn’t want to try hexadecimal editors of reencode my text manipulations from windows. So, finally I downloaded an ubuntu and initited my laptop from it. The SD card automounted and I could change my folder permissions.

Thanks to all for your advices!

1 Like

That’s a really bad idea. You never install user level software into /usr/bin. You install it to /home/osmc/bin, or if it needs to be a different user you create a new user and install it to that users bin.