Score:0

Recovered /usr/bin folder - Problem with permissions

cn flag

I accidentally deleted my /usr/bin/ folder on my Raspberry Pi with Ubuntu server. Luckily I had a backup. Its a little bit old, but not much changed since then. I thought I could just copy the old bin from the backup, which is in another computer, to the SD-Card from my raspberry.

It worked, ubuntu server is working again. Sudo is not. I suppose because I created the new bin on another computer (another user) the permissions are all messed up. It brings the following error:

/usr/bin/sudo must be owned by uid 0 and have the setuid bit set

How can I restore the standard permissions for /usr/bin? Can I do this without logging out and login again as root? (deleted all the files in usr/bin typing in rm -rf *) Because I don't know how to do this in ubuntu server. I'm accessing my server over ssh.

Do I have to reinstall the packages like this?

apt-get --reinstall install $(grep -l '^/usr/bin/' *.list | sed 's/\.list$//')

Thanks for your time.

Score:0
cn flag

So I'm answering my question myself. I like this. You search, try and learn something.

The trick is to copy the permissions with the file. I actually learned this searching for how to backup my server. Great video by the way: https://www.youtube.com/watch?v=KTayZIou-1M

I realised that you can copy the original permissions with the files, leaving them intact. And here is how: How do I copy a folder keeping owners and permissions intact?

So I just:

sudo cp -rp backup/usr/bin SD-card/usr/bin

from my other computer with the backup to the raspberry SD-card.

Now with this knowledge I will try to restore my complete system from the backup files. Just to have a clean system again.

Wish me luck. ;)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.