Ubuntu – Any recovery from this? sudo chmod 600 .*

bashchmodpermissionssudo

WARNING – DO NOT RUN THE MENTIONED COMMAND

So it seems I did something pretty dumb here to put it mildly. I was attempting to change the permissions for a few files in a directory that all started with . to read/write for sudo/root only.

My attempt at changing several files at once seems to have done something pretty horribly global. While inside a directory (wasn't at root dir) I ran sudo chmod 600 .* and well, I'm posting this from my phone now… I still have the terminal window open at the moment, but I'm quite sure if the laptop goes to sleep I'm completely done. Hilariously that means there is a slight urgency to this question.

Oh and this seems to have changed permissions damn near everywhere I'm guessing. I can't even run the ls or cd .. commands. An attempt of cd /home/brian or cd ~ give the error bash: cd: /home/brian: Permission Denied and any attempt at a sudo command just says bash: /usr/bin/sudo: Permission Denied

I am afraid of rebooting, no clue if there is any built in recover from something this dumb, but figured I would try to ask here before making things any worse. I'm a pretty new Linux as my main OS convert and been advocating for it a bit lately, but ouch, this one stings a bit. Any thoughts of things to try would be immensely appreciated.

EDIT: I wanted to provide clarification on how/where this command was executed. This was executed from /.atx $, just an arbitrary directory, but more details below.

While logged in as my regular username brian, I had a terminal open to /.atx that contained three config type text only files. Each filename started with a .. That directory/name/the files aren't any part of a common package, just an arbitrary set of configs I was programmatically moving around. Files contained some SQL server connection string info and just wanted them semi-obscured.

Best Answer

Whew, the recovery here was actually smoother than I expected and everything SEEMS in pretty good shape again.

Huge thanks to @CharlesGreen for an explanation of how that command extended up a directory. Also thanks to @Panther for info on getting into recovery mode for a somewhat related issue. (if you both want to re-share your comments as answers I'd upvote them)

Fortunately, unlike the linked post, this seems to have had a very straightforward fix. It seems when I ran the sudo chmod 600 .* command from only one directory under / it expanded the .* portion UP to the true root directory altering permissions of . from / causing every other permission to fall over.

The "fix" for this was to boot into recovery mode, re-mounting the drive as read/write, going to the main root (cd /), and then chmod +rx .. After a reboot, everything looks to be back to normal.

Moral of the story, executing a command on .* can at least sometimes impact the directory ABOVE the current. I had intended to only impact files that started with ....oops.

Huge thanks to everyone that commented and helped.

Related Question