You are not logged in.

#1 2013-07-26 21:49:07

drasticraft
Member
From: mars
Registered: 2013-07-05
Posts: 55
Website

[SOLVED]I marked everything as executable!

Is there any commands I can run to fix this?

I ran

# chmod -r 777 ~/jrockit

And somehow it marked everything in the drive as executable.

Last edited by drasticraft (2013-07-26 22:38:54)

Offline

#2 2013-07-26 22:10:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]I marked everything as executable!

What do you mean by drive? It should work for ~/jrockit directory - did you mount a drive there? If so, what's on it? What filesystem?
Running 'chmod' with different octal numbers should remove the executable bit.

Last edited by karol (2013-07-26 22:12:54)

Offline

#3 2013-07-26 22:12:10

drasticraft
Member
From: mars
Registered: 2013-07-05
Posts: 55
Website

Re: [SOLVED]I marked everything as executable!

What I mean is evrything in my Arch installation is now rwxrwxrwx.

Offline

#4 2013-07-26 22:12:41

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED]I marked everything as executable!

Not a Sysadmin issue, moving to NC...

Also, please choose a more appropriate title: https://wiki.archlinux.org/index.php/Fo … ow_to_Post


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2013-07-26 22:13:47

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]I marked everything as executable!

This is not good.  So everything on the drive has 777 permissions?

There are a couple of things you could do.  You could reinstall all packages under the assumption that they will be rewritten to the drive with the correct permissions.  But this doesn't take into account all the stuff that is generated by various applications. There are some that require certain permissions to run.

The other thing you could do is simply salvage the configs and user data, and reinstall.  This is one of those rare cases where fixing the things might not be worth the trouble.  For even if you get things running again, you are likely to have not fixed everything and at some point (probably sooner rather than later) run into issues. 

Maybe someone around here might have a better idea... but I don't know of anything better.

Offline

#6 2013-07-26 22:14:03

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]I marked everything as executable!

I don't see how could this work for the whole system as you used '~/jrockit' as the argument. Is this some special directory?

Offline

#7 2013-07-26 22:15:02

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]I marked everything as executable!

If the whole drive is now rwxrwxrwx, then drasticraft obviously didn't type in the command he/she thought.

Offline

#8 2013-07-26 22:31:10

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: [SOLVED]I marked everything as executable!

Whether it is or not, drasticraft didn't type in the command reported above.

$ mkdir -p /tmp/a/b/c/d
$ echo hi > /tmp/a/b/c/d/e
$ echo bye > /tmp/a/b/f
$ chmod -r 777 /tmp/a
chmod: cannot access ‘777’: No such file or directory
$ l /tmp/a
ls: cannot open directory /tmp/a: Permission denied

Now admittedly I didn't run this as root and the OP apparently ran it as root on a file or directory at /root/jrockit, but I am still betting it wasn't the command reported.

The result is apparently equivalent to chmod 311 /tmp/a and is not applied recursively. I'm not entirely sure why this is the result but that's what I get.

Last edited by cfr (2013-07-26 22:34:23)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2013-07-26 22:35:30

mostlyharmles
Member
Registered: 2013-07-26
Posts: 11

Re: [SOLVED]I marked everything as executable!

You did that as root? why? Honestly, your best bet is to just restore from backups, or if you didn't backup, re-install. If every permission on the drive is 777 then you have some very serious issues. Hopefully you can just take some lessons home from this. Never take root lightly. be excedingly cautious with the -r flag for chmod, and never apply 777 on things that don't specificly need 777 permissions. I can't imagine a situation where even a home folder would need 777 permissions. This is one of those "what the heck was I thinking moments." Everyone gets them. As far as I know Arch doesn't keep track of file permisions outside of the files themselves, so there is no way to set every file back to what they were before the goof up.

Offline

#10 2013-07-26 22:35:31

drasticraft
Member
From: mars
Registered: 2013-07-05
Posts: 55
Website

Re: [SOLVED]I marked everything as executable!

Well, is there any other way my installation could be trashed like this?

You can rule out hostile action, It's a laptop and SSH is not permitted.

EDIT: Most definitely a "what the hell was I doing" moment.

Last edited by drasticraft (2013-07-26 22:37:20)

Offline

#11 2013-07-26 22:36:01

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]I marked everything as executable!

Probably he meant '-R' instead of '-r'.

I agree with WonderWoofy that reinstalling is the safest option.
Tips for the future:
1. Don't run as root unless you really need to.
2. Be very careful when you operate as root.

Offline

#12 2013-07-26 22:38:38

drasticraft
Member
From: mars
Registered: 2013-07-05
Posts: 55
Website

Re: [SOLVED]I marked everything as executable!

karol wrote:

1. Don't run as root unless you really need to.
2. Be very careful when you operate as root.

Alright, I'll keep that in mind.


To the CD drive!

Offline

#13 2013-07-26 22:38:40

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]I marked everything as executable!

drasticraft wrote:

Well, is there any other way my installation could be trashed like this?

Not too long ago, there was a user who chown'ed the entire filesystem to themselves... which I think is as bad if not worse.

Offline

#14 2013-07-26 22:41:02

mostlyharmles
Member
Registered: 2013-07-26
Posts: 11

Re: [SOLVED]I marked everything as executable!

My guess is something happened in the recursion that hopped chmod out onto your hard drive. Without knowing exactly what happened, we can only speculate and stare gapejawed at a pretty big oops. With root access chmod could merrily triapse across the filesystem,...possibly it followed a symlink?

Offline

#15 2013-07-26 22:42:02

drasticraft
Member
From: mars
Registered: 2013-07-05
Posts: 55
Website

Re: [SOLVED]I marked everything as executable!

mostlyharmles wrote:

possibly it followed a symlink?

There weren't any in there...

Offline

#16 2013-07-26 22:44:34

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]I marked everything as executable!

I'm truly curious.  What does your bash history say you used as the command?  (Or your zsh, or tcsh, or whatever history)

Offline

#17 2013-07-26 22:48:09

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: [SOLVED]I marked everything as executable!

Well, what would do it would be to chmod with the -R flag and permissions 777 on / as root. Note that I am not going to write this command out as it might be executed in case of anybody is too trigger-happy with copy-paste.

I'm not sure chowning to self is worse. At least most stuff in your own home would be OK in that case (assuming "themselves" meant their user account and not root's). In this case, stuff under home is going to be wrong as well and that makes it more of a pain to recover i.e. you can't *just* reinstall the system and leave /home/<username> intact. You'll need to reinstall and sort your home directory out.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#18 2013-07-26 23:07:22

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: [SOLVED]I marked everything as executable!

Why does chmod -r <dir> apply permissions 311 to it and chmod -r <file> apply permissions 200 to it? That is, I'm not asking about the difference but why does chmod -r pick these permissions? In fact, why does it do anything at all?

As far as I can tell -r is undocumented - it isn't in the man page or help for the command, at least. So why doesn't the command fail as it would if just tried chmod <dir/file>?

Last edited by cfr (2013-07-26 23:08:23)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#19 2013-07-26 23:25:37

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED]I marked everything as executable!

Speaking of chmod man page, I think I can add a chmod-specific tip:

       --preserve-root
              fail to operate recursively on '/'

If you alias chmod to 'chmod -preserve-root' (both for the users and root), https://bbs.archlinux.org/viewtopic.php … 6#p1304546 fails, right?



'chmod -r' is a valid command - it removes the read bit.

Offline

#20 2013-07-26 23:30:23

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: [SOLVED]I marked everything as executable!

karol wrote:

'chmod -r' is a valid command - it removes the read bit.

Damn it! Of course, how could I miss that? Thanks for pointing out the incredibly obvious... I'm such an idiot.

EDIT: Is it possible to set aliases which apply to sudo without preserving the calling user's environment entirely? I have a bunch of these safety aliases for root and my own user (more for root but some for my user) but they don't stop me doing daft things with sudo...

Last edited by cfr (2013-07-26 23:36:07)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB