It sounds like you have messed up the permissions of /usr/bin/sudo. That could be difficult to repair, especially if you do not understand how it happened.bserce123 wrote:'sudo must be owned by uid 0 and have setuid bit set'
Don't do that. It is just wrong.bserce123 wrote:I've tried chown-ing and chmod-ing and putting sudo in front of it all after rtf-ing manuals for some hours in order to change ownership of my /usr/local/bin directory from root to my current user (pi)
Code: Select all
# This is the file...
topguy@lounge:~$ ls -l test.sh
-rwxrw-r-- 1 topguy topguy 156 jan. 8 2016 test.sh
#copying it.
topguy@lounge:~$ sudo cp test.sh /usr/local/bin/
#Checking rights and see that its only eXecutable by root.
topguy@lounge:~$ ls -l /usr/local/bin/test.sh
-rwxr--r-- 1 root root 156 juni 2 21:57 /usr/local/bin/test.sh
#Change rights and verify that other users also has the 'x' bit.
topguy@lounge:~$ sudo chmod ugo+x /usr/local/bin/test.sh
topguy@lounge:~$ ls -l /usr/local/bin/test.sh
-rwxr-xr-x 1 root root 156 juni 2 21:57 /usr/local/bin/test.sh
It should be rather easy to fix...but the easy way that comes mind would involve a second SD card and an SD to USB adapter.jojopi wrote:It sounds like you have messed up the permissions of /usr/bin/sudo. That could be difficult to repair, especially if you do not understand how it happened.bserce123 wrote:'sudo must be owned by uid 0 and have setuid bit set'
We've been advised in these forums to have personal projects in usr/local/bin for being called by crontab but copying files into that directory or editing them to improve the scope once they are in there when root rules the roost, is not what we want. As its our Raspi, we have one project that we rely on, that runs 24/7 on this dedicated computer, that is what we want to do. Something else we want to do is to find out how to do it safely and do it safely enough for our purposes. What we don't want to do is tread on anyone else's ownership rights in the process.topguy wrote:You should have VERY good reasons for wanting to change the ownership rights of /usr/local/bin.
So tell us what your real problem is.
Everything we have done so far seems still to be working as intended and our Raspi seems to be doing a good job stopping us doing what it doesn't like, so we think we are probably still OK. We're slowly learning how to find out how to do things safely, and that is the main object of this present exercise. If you would kindly point us to some document that says not to use usr/local/bin, and why, we'll gladly take on board any lesson to be learned, and thank you.CarlRJ wrote:If you want a bin directory that is easily writable/usable by user pi, do mkdir ~pi/bin to create one under your home directory. /usr/local/bin isn't meant to be writable by everyone.
It also sounds like you've mucked up the ownership or permissions of sudo (posting the output of ls -l /usr/bin/sudo would help diagnose this), which is a bit tricky to fix, as all the simple ways involve using... sudo.
*Who* has been advising you to put personal projects into /usr/local/bin? (Can you provide a link to that advice?)bserce123 wrote:We've been advised in these forums to have personal projects in usr/local/bin for being called by crontab but copying files into that directory or editing them to improve the scope once they are in there when root rules the roost, is not what we want. As its our Raspi, we have one project that we rely on, that runs 24/7 on this dedicated computer, that is what we want to do. Something else we want to do is to find out how to do it safely and do it safely enough for our purposes. What we don't want to do is tread on anyone else's ownership rights in the process.topguy wrote:You should have VERY good reasons for wanting to change the ownership rights of /usr/local/bin.
So tell us what your real problem is.
Fixed itW. H. Heydt wrote: E.g. sudo mkdir /usr/local/bin/pi ; sudo chown pi /usr/local/bin/pi
That would defeat the object of putting things in the /usr/local/bin directory as it would no longer be in the run PATH.W. H. Heydt wrote:Now something you *could* do would be to create a directory within /usr/local/bin and change the ownership of it to a specific user ID. E.g. sudo mkdir /usr/local/bin/pi ; chown pi /usr/local/bin/pi
The difficult part is not fixing sudo, but knowing what else is broken. There is no logical reason to mess with /usr/bin/sudo specifically, so this is just as likely to have been a wildcard or recursive change gone badly wrong.W. H. Heydt wrote:It should be rather easy to fix...but the easy way that comes mind would involve a second SD card and an SD to USB adapter.
Bad advice. Cron can execute stuff from anywhere - just put the full executable path in the crontab. For stuff run by root (which it probably is) I think that's good practice anyway - root should never rely on the PATH setting, in my opinion (you can't immediately tell what PATH is, you might not be running what you think you are, you always want to know exactly what root is running).bserce123 wrote: We've been advised in these forums to have personal projects in usr/local/bin for being called by crontab
This makes no sense to me, sorry. Why don't you want to copy files into a directory owned by root? That directory should be owned by root, because anything put there will be run by all users, so you do want root (the overall ultimate controller of the system) to control what gets written in there. You don't want any ordinary user adding files there, so you don't want it owned by an ordinary user. You need to explain why you think it's not what you want.bserce123 wrote: but copying files into that directory or editing them to improve the scope once they are in there when root rules the roost, is not what we want.
Putting a file in the /usr/local/bin directory is not treading on anyone's ownership rights. I think you might be confused about what ownership means - root being owner of a directory doesn't mean that all files in that directory should be owned by root. That doesn't work at all - root owns the / directory, so that would mean that root would need to own all the files on the whole system. Root owns /usr/local/bin (and that's the way it should be) and if you want to put a file in there you assume root authority and put it in there. Job done. You can put it in there and then use root authority to change the owner of the file to whatever owner you want the file to have, if that's what you want for some reason. That is, use sudo cp to copy the file in, and then if you want use sudo chown to change the owner and/or sudo chmod to change the permissions.bserce123 wrote:As its our Raspi, we have one project that we rely on, that runs 24/7 on this dedicated computer, that is what we want to do. Something else we want to do is to find out how to do it safely and do it safely enough for our purposes. What we don't want to do is tread on anyone else's ownership rights in the process.
Eh? I can't point you at any document that says not to stamp on your pi wearing clogs and then boil it in vinegar. I really wouldn't advise doing that, though. /usr/local/bin should be used, but it should be used for the right thing, which is as the place where you put programs or scripts that you want all users on your system to be able to run easily. It's not intended for cron scripts (though you could put them there if you want, if for example you had a script you wanted to run regularly and you wanted users to be able to run it).bserce123 wrote: If you would kindly point us to some document that says not to use usr/local/bin, and why, we'll gladly take on board any lesson to be learned, and thank you.
Quite a few hours went into burning midnight oil learning from the wisdom lately dispensed in this topic - for which many thanks, and hopes we have not annoyed too many with our intransigence. What we've done since:-achrn wrote:Bad advice. Cron can execute stuff from anywhere - just put the full executable path in the crontab. For stuff run by root (which it probably is) I think that's good practice anyway - root should never rely on the PATH setting, in my opinion (you can't immediately tell what PATH is, you might not be running what you think you are, you always want to know exactly what root is running).bserce123 wrote: We've been advised in these forums to have personal projects in usr/local/bin for being called by crontab
This makes no sense to me, sorry. Why don't you want to copy files into a directory owned by root? That directory should be owned by root, because anything put there will be run by all users, so you do want root (the overall ultimate controller of the system) to control what gets written in there. You don't want any ordinary user adding files there, so you don't want it owned by an ordinary user. You need to explain why you think it's not what you want.bserce123 wrote: but copying files into that directory or editing them to improve the scope once they are in there when root rules the roost, is not what we want.
Putting a file in the /usr/local/bin directory is not treading on anyone's ownership rights. I think you might be confused about what ownership means - root being owner of a directory doesn't mean that all files in that directory should be owned by root. That doesn't work at all - root owns the / directory, so that would mean that root would need to own all the files on the whole system. Root owns /usr/local/bin (and that's the way it should be) and if you want to put a file in there you assume root authority and put it in there. Job done. You can put it in there and then use root authority to change the owner of the file to whatever owner you want the file to have, if that's what you want for some reason. That is, use sudo cp to copy the file in, and then if you want use sudo chown to change the owner and/or sudo chmod to change the permissions.bserce123 wrote:As its our Raspi, we have one project that we rely on, that runs 24/7 on this dedicated computer, that is what we want to do. Something else we want to do is to find out how to do it safely and do it safely enough for our purposes. What we don't want to do is tread on anyone else's ownership rights in the process.
Eh? I can't point you at any document that says not to stamp on your pi wearing clogs and then boil it in vinegar. I really wouldn't advise doing that, though. /usr/local/bin should be used, but it should be used for the right thing, which is as the place where you put programs or scripts that you want all users on your system to be able to run easily. It's not intended for cron scripts (though you could put them there if you want, if for example you had a script you wanted to run regularly and you wanted users to be able to run it).bserce123 wrote: If you would kindly point us to some document that says not to use usr/local/bin, and why, we'll gladly take on board any lesson to be learned, and thank you.
It is right to use /usr/local/bin (for its intended purpose).
It is wrong to change the owner of /usr/local/bin.
It is wrong to change the owner or permissions of files in /usr/bin.