LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   lease help locked out of my system! (https://www.linuxquestions.org/questions/linux-newbie-8/lease-help-locked-out-of-my-system-4175540932/)

Deletere 04-27-2015 04:59 PM

lease help locked out of my system!
 
I accidentally hit run on the following:

sudo chmod -R go+r-x u+rwx /

and now I can not preform any command

Help would be much appreciated!

D

astrogeek 04-27-2015 05:07 PM

Knowing which distro and version would help those trying to answer.

If you have a root account, you may be able to login as root and fix some things, although there is no simple way to put it all back just like it was.

Alternatively, you should be able to boot to the install DVD or a system rescue type DVD and mount the drive. Once mounted you would be able to change permissions, but still no single command will do that for you.

Honestly, the best way to recover from such extensive changes would be to secure backups of your data from the drive and reinstall in most cases.

suicidaleggroll 04-27-2015 05:16 PM

You essentially removed execute permission from anybody but the owner for all files and directories on the system. Since root is the owner of most of those files/dirs (at least the important ones), you should still be able to log in as root and fix what needs fixing.

That said, it would probably be faster to just reinstall.

Deletere 04-27-2015 05:27 PM

Thanks guys it is a raspberry Pi running Raspbian. Unfortunately I was running as the root user what happened. I typed:

sudo chmod -R go+r-x u+rwx / [FolderName]

and just after hitting enter realised that I had put in a space where I didn't want to.

Is there anyway I can get files off the system, either by hooking it up to another computer or any other way as I would prefer not to lose everything due to a reinstall.

Also if there is a long way to restore access (eg connecting the hard drive directly to another computer and manually changing files) I am happy to do that as I have a lot of work on it and this happened prior to me backing up the image.

suicidaleggroll 04-27-2015 05:55 PM

If it's an RPi then just pull out the SD card and plug it into another computer to grab files and/or fix the permissions.

FYI - "sudo command" does not run "command" as the root user, it runs "command" as your regular user but with super-user privileges. In instances like this, your "user" is still your regular user, not root. In the future, you can run "sudo passwd root" to give the root account a real password so you can log into it in cases like this when the "regular" user is inaccessible.

Deletere 04-27-2015 05:57 PM

Quote:

Originally Posted by suicidaleggroll (Post 5354122)
If it's an RPi then just pull out the SD card and plug it into another computer.


Yeah That's what I was planning (not disconnecting yet as once I do I will not be able to re log on) but can I change permissions or do I still need to to a reinstall?

suicidaleggroll 04-27-2015 06:42 PM

You can change permissions, but you'll have to do it for every single directory in the filesystem. It would likely be faster to reinstall.

joe_2000 04-28-2015 04:21 PM

Quote:

Originally Posted by Deletere (Post 5354123)
Yeah That's what I was planning (not disconnecting yet as once I do I will not be able to re log on) but can I change permissions or do I still need to to a reinstall?

I would not waste a single minute to try and fix this. It would be so time-consuming and error prone that you'll eventually end up reinstalling anyways. Grab your data, reinstall and treat it as a lesson learned for the future.

If it makes you feel better, I have been there, too, as probably most of us. It typically doesn't happen twice to the same person though ;-)

jlinkels 04-28-2015 08:55 PM

Quote:

Originally Posted by suicidaleggroll (Post 5354122)
FYI - "sudo command" does not run "command" as the root user, it runs "command" as your regular user but with super-user privileges. In instances like this, your "user" is still your regular user, not root.

I am sorry, but I don't think it is true. Sudo runs a command as root. Therefor settings in your home directory like .vimrc are not used while editing a file with sudo. This demonstrates it pretty much I think:
Code:

jlinkels@jlinkels-lt:/tmp$ whoami
jlinkels
jlinkels@jlinkels-lt:/tmp$ sudo whoami
root

jlinkels

jlinkels 04-28-2015 08:57 PM

Quote:

Originally Posted by joe_2000 (Post 5354677)
I would not waste a single minute to try and fix this.

+1.
Put the SD card in something and get the files off. And you don't reinstall raspbian. You simply dd the image again onto the SD card. And then put your files back.

jlinkels

suicidaleggroll 04-28-2015 09:05 PM

Quote:

Originally Posted by jlinkels (Post 5354795)
I am sorry, but I don't think it is true. Sudo runs a command as root. Therefor settings in your home directory like .vimrc are not used while editing a file with sudo. This demonstrates it pretty much I think:
Code:

jlinkels@jlinkels-lt:/tmp$ whoami
jlinkels
jlinkels@jlinkels-lt:/tmp$ sudo whoami
root

jlinkels

Hm - I think you're right, thanks for the correction.

astrogeek 04-29-2015 01:38 AM

Quote:

Originally Posted by suicidaleggroll (Post 5354801)
Hm - I think you're right, thanks for the correction.

I suspect that what you had in mind is that when running sudo you still have the normal user's environment - particularly the PATH. As a result even though you are root, you must still give absolute paths for most /sbin and /usr/sbin executables.


All times are GMT -5. The time now is 11:38 PM.