LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2015, 04:59 PM   #1
Deletere
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Rep: Reputation: Disabled
Unhappy 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
 
Old 04-27-2015, 05:07 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,085
Blog Entries: 1

Rep: Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150
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.

Last edited by astrogeek; 04-27-2015 at 05:17 PM.
 
Old 04-27-2015, 05:16 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,398

Rep: Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017
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.
 
Old 04-27-2015, 05:27 PM   #4
Deletere
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.

Last edited by Deletere; 04-27-2015 at 05:33 PM.
 
Old 04-27-2015, 05:55 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,398

Rep: Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017
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.

Last edited by suicidaleggroll; 04-27-2015 at 06:01 PM.
 
Old 04-27-2015, 05:57 PM   #6
Deletere
LQ Newbie
 
Registered: Apr 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
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?
 
Old 04-27-2015, 06:42 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,398

Rep: Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017
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.
 
Old 04-28-2015, 04:21 PM   #8
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 812

Rep: Reputation: 216Reputation: 216Reputation: 216
Quote:
Originally Posted by Deletere View Post
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 ;-)
 
1 members found this post helpful.
Old 04-28-2015, 08:55 PM   #9
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636
Quote:
Originally Posted by suicidaleggroll View Post
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
 
Old 04-28-2015, 08:57 PM   #10
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636
Quote:
Originally Posted by joe_2000 View Post
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
 
1 members found this post helpful.
Old 04-28-2015, 09:05 PM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,398

Rep: Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017
Quote:
Originally Posted by jlinkels View Post
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.
 
Old 04-29-2015, 01:38 AM   #12
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,085
Blog Entries: 1

Rep: Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150Reputation: 2150
Quote:
Originally Posted by suicidaleggroll View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ubuntu system may be more locked down than a certified Windows 8 system LXer Syndicated Linux News 0 06-19-2012 03:20 PM
mythbuntu locked up my system! 1117 Linux - Desktop 4 07-25-2010 04:45 PM
some sort of dhcp lease alert script/email/popup system? Predatorian Linux - Server 2 10-21-2009 12:26 PM
locked out of my own system... ctsiow Linux - General 2 06-13-2009 01:44 PM
Help, I am Locked from my system Kaiser_Sose Linux - Software 6 02-03-2004 07:39 AM


All times are GMT -5. The time now is 05:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration