It's all about those little file mode bits

247 points · 73 comments · view on lemmy.world

73 Comments

W98BSoD@lemmy.dbzer0.com · 108 pts · 3d (2 replies)

Funkt4st1c@lemmy.world · 26 pts · 3d

This is drake erasure and I'm LOVING EVERY MINUTE OF IT, JERRY

trashman@feddit.org · 13 pts · 3d

Yo dawg, heard you like memes

gigaqps@lemmy.world · 69 pts · 3d (10 replies)

But those are different

Ephera@lemmy.ml · 60 pts · 3d (8 replies)

Yeah, not only does +x leave read/write permissions untouched, it also only makes it executable for the user, not for everyone and their cat.

MrChewy@lemmy.world · 25 pts · 3d (5 replies)

Cat doesn't execute anything tho, it just reads and gives output

SaharaMaleikuhm@feddit.org · 10 pts · 3d (2 replies)

The cat command executes the cat program.

quantumvoid0@programming.dev · 5 pts · 3d (1 reply)

What happens when u try to cat the cat program, is that considered reading or executing

NominatedNemesis@reddthat.com · 5 pts · 2d

Both, they are not mutually exclusive.

NominatedNemesis@reddthat.com · 5 pts · 2d

Except if you use kitty terminal emulator with unsecure remote access. Issue

Then with cat, you could execute arbitrary commands...

fartographer@lemmy.world · 1 pts · 1d

Or am I???

x='dumb.txt' && echo "ls | grep $x && cat $x && rm -v $x" > $x && cat $x | bash

dimmuborgnine@lemmy.world · 5 pts · 1d

If your cat isn’t the first entry in /etc/sudoers I’m not sure I want to know you

dimmuborgnine@lemmy.world · -1 pts · 1d

If your cat isn’t the first entry in /etc/sudoers I’m not sure I want to know you

alecsargent@lemmy.zip · 3 pts · 3d

Had to be done for the joke. :)

morto@piefed.social · 63 pts · 3d

chmod 666 so only the devil can execute it

rumschlumpel@feddit.org · 37 pts · 3d (5 replies)

When I start fucking with chmod, it happens way too often that what I want to do only works after I executed chmod 777...

renegadespork@lemmy.jelliefrontier.net · 56 pts · 3d

May I interest you in a nice “chown”?

rImITywR@lemmy.world · 38 pts · 3d (2 replies)

chmod -R 777 /

Why the fuck am I still getting permission errors

renegadespork@lemmy.jelliefrontier.net · 30 pts · 3d

sudo

voytrekk@sopuli.xyz · 6 pts · 3d

Selinux

quarrel4you@piefed.social · 3 pts · 2d

You can actually do chmod +777,u+rwx,go-w foo to make the logic easier if you want to force a starting assumption.

Maxxie@piefed.blahaj.zone · 31 pts · 3d

this but in reverse 🤷‍♀️

neopenguin@lemmy.world · 18 pts · 3d

If you don't add the leading digit (out of respect) for the sticky/setgid/setuid bits, do you even Linux?

renegadespork@lemmy.jelliefrontier.net · 16 pts · 3d (12 replies)

700 cause I’m selfish.

Dirk@lemmy.ml · 8 pts · 3d (11 replies)

700 is the only sane answer for directories inside $HOME.

renegadespork@lemmy.jelliefrontier.net · 5 pts · 3d (7 replies)

Nah, there’s a lot of config files in there that other programs need to read.

wheezy@lemmy.ml · 13 pts · 3d (3 replies)

Unfortunately. I really wish $HOME was reserved for files I create myself. I know. I can create my own shit for that. But, I really wish every single random project I download to fuck around with didn't drop a config directory or file in there. ITS MY HOME.

meekah@discuss.tchncs.de · 13 pts · 3d (2 replies)

I mean, having config files in there makes a lot of sense. It allows you to move your home to some other machine/install and immediately feel at home, because everything is configured to your liking.

Now, the fact that many apps create their own directory instead of putting their stuff in ~/.config is pretty annoying.

wheezy@lemmy.ml · 5 pts · 2d

Yeah. That's more my frustration. That it's implented poorly by most people. I don't think that trying to change the standard by "adding another standard" would be helpful. Just minor frustration. Which usually leads me to putting all my organized directories and shit in a dedicated location. And I just let /home be the clutter that it is.

vaionko@sopuli.xyz · 5 pts · 3d

Also for multi user systems it's handy that each user gets their own configs

Dirk@lemmy.ml · 2 pts · 3d (2 replies)

The programs usually run in user context and have access to the files.

Even if thinking very hard I cannot come up with a scenario where a program that does not run in user context needs access to user files.

renegadespork@lemmy.jelliefrontier.net · 1 pts · 3d (1 reply)

Usually, but there might be services running as other users that reference those configs. It really just depends on what’s on your system. Obviously you can make 700 work, but it might require tweaking some stuff.

Dirk@lemmy.ml · 2 pts · 3d

It really just depends on what’s on your system.

Yes, this is what I wonder.

I use Linux since ca. 2005 and never ever had a program not working because it could not read a user’s $HOME contents.

libewa@feddit.org · 2 pts · 3d (2 replies)

macOS by default makes /Users/* only readable by the owner, except for $HOME/Public, which is drwxr-xr-x, and $HOME/Public/Postbox, which is drwx-w--w-

DarkDarkHouse@lemmy.sdf.org · 2 pts · 2d (1 reply)

I gotta ask why they put Public in home

libewa@feddit.org · 2 pts · 2d

Because it's a user-specific folder that says "This is mine, but you can see it."

SaharaMaleikuhm@feddit.org · 15 pts · 3d (1 reply)

Nope, +x for life

nibbler@discuss.tchncs.de · 1 pts · 3d
[ removed ]
Wfh@lemmy.zip · 14 pts · 3d (6 replies)

chmod -R 600 ~/, because I dont trust anyone, not even myself.

palordrolap@fedia.io · 12 pts · 3d (5 replies)

I forgor the tilde and its taking a long time. wat do

the_strange@feddit.org · 12 pts · 3d

sudo rm -rf / --no-preserve-root

Start from scratch

clay_pidgin@sh.itjust.works · 2 pts · 3d (3 replies)

Tilde is a shortcut to /home/palordrolap

palordrolap@fedia.io · 3 pts · 2d (2 replies)

False. It's a shell synonym for /home/ah-ha-ha-nice-try-you-are-not-getting-my-real-homedir-name

... it's a PITA to type out longhand, let me tell you.

clay_pidgin@sh.itjust.works · 2 pts · 1d (1 reply)

Ah, I see. I thought that you had forgotten what the tilde does, not that you ran the command without it!

palordrolap@fedia.io · 2 pts · 1d

I was being a silly goose and pretending I was more clueless than I actually am.

(Probably not by as much as I'd like to think.)

cupcakezealot@piefed.blahaj.zone · 12 pts · 3d

chmod -R 777 / galaxy brain

Nyadia@lemmy.blahaj.zone · 11 pts · 3d (2 replies)

I don't use chmod nearly often enough to remember these numbers. I know there's a mathematical way to figure it out, but I cba to do that when u+wrx more or less tells me exactly what it does (grant the User Write, Read, and eXecute permissions)

timbuck2themoon@sh.itjust.works · 8 pts · 2d (1 reply)

4 read, 2 write, 1 execute.

That's it. Add them up for whatever you want.

naevaTheRat@lemmy.dbzer0.com · 3 pts · 1d

and digits are sticky, owner, group, all

BigBrownBeaver@lemmy.world · 7 pts · 2d (1 reply)

chmod -R ug+rwX,o=r *

anarchy79@lemmy.world · 2 pts · 2d

Such a beautiful language.

undefinedTruth@lemmy.zip · 6 pts · 3d

chmod 755 for when setting permissions to directories. chmod +x for making something executable right when I am about to run it.

Unpigged@lemmy.dbzer0.com · 5 pts · 3d

I like to chmod it chmod it

red_bull_of_juarez@lemmy.dbzer0.com · 5 pts · 3d (3 replies)

u=rwX,g=rX,o=rX because this won't make every file executable, only folders.

quarrel4you@piefed.social · 2 pts · 2d (1 reply)

Careful: chmod -X also looks for any existing exec bits:

$ umask 0
$ >foo >bar
$ ls -al foo bar
-rw-rw-rw- 1 user group 0 Sep 10 00:00 bar
-rw-rw-rw- 1 user group 0 Sep 10 00:00 foo
$ chmod o+x foo
$ ls -al foo bar
-rw-rw-rw- 1 user group 0 Sep 10 00:00 bar
-rw-rw-rwx 1 user group 0 Sep 10 00:00 foo
$ chmod u=rwX,g=rX,o=rX foo bar
$ ls -al foo bar
-rw-r--r-- 1 user group 0 Sep 10 00:00 bar
-rwxr-xr-x 1 user group 0 Sep 10 00:00 foo
red_bull_of_juarez@lemmy.dbzer0.com · 2 pts · 2d

This is exactly what I expect, so I never got tripped up by this. But yes, it's worth pointing out that this will expand the executable flag on files that are already executable and set it on folders too. But not set it on files that aren't executable at all.

eyesaremosaics@lemmy.zip · 1 pts · 3d

Looks like a handy flag

DrunkAnRoot@sh.itjust.works · 4 pts · 2d (11 replies)

real question is how do you pronounce chmod

Bakkoda@lemmy.world · 9 pts · 2d

c h mod

recursivethinking@lemmy.world · 5 pts · 2d

shmod. and then cho-wn (ch'own? cho-un?)

and of course, hweel (jk on this one)

daniskarma@lemmy.dbzer0.com · 4 pts · 2d

"chemod"

flandish@lemmy.world · 3 pts · 2d

“change mod”

fleebleneeble@reddthat.com · 2 pts · 1d

Shmaude

AstroLightz@lemmy.world · 2 pts · 2d

"c h m o d"

Just like "l s" and "p a c m a n"

Magnum@infosec.pub · 2 pts · 2d

The CH from channel and then mod

Tiger_Man_@szmer.info · 1 pts · 1d

hmod

alecsargent@lemmy.zip · 0 pts · 2d (2 replies)

I pronounce it chmod, you?

anarchy79@lemmy.world · 3 pts · 2d

I pronounce it the way it's written.

DrunkAnRoot@sh.itjust.works · 3 pts · 2d

i say c h then mod

PerogiBoi@lemmy.ca · 4 pts · 3d

Chmod 777 I live erratically without consequence.

Tiger_Man_@szmer.info · 3 pts · 1d

not giving a fuck about proper file perms is fine as long as its not a server

a_non_monotonic_function@lemmy.world · 2 pts · 1d

Why? I mean not Drake because Drake sucks

My specify every permission every time? That's just going to create arrows.

Matty_r@programming.dev · 2 pts · 3d

Dont forgot setfacl

vala@lemmy.dbzer0.com · 1 pts · 2d

chmod -R -x *