this post was submitted on 20 Aug 2026
328 points (99.7% liked)

Linux

67120 readers
734 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 7 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] jabjoe@feddit.uk 2 points 34 minutes ago

Got to love UNIX's everything is a file.

ProcFS is from Plan9. https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs#/proc

Plan9 is worth a deep dive, but maybe not worth running. It is more UNIX than UNIX. (Also where UTF8 came from.)

[–] four@lemmy.zip 29 points 8 hours ago

I'm surprised it doesn't mention that /proc/self automagically points to the directory of the current process. So if you're writing a program, you can just look there for information about itself

[–] PowerCrazy@lemmy.ml 8 points 6 hours ago

I didn't know any of this. Amazing. I usually just look at /proc/net/ for routes and bonding config etc.

[–] Unreliable@lemmy.ml 2 points 4 hours ago

/proc is quite useful when it comes to hiding root on Android.

[–] FluidBeef@quokk.au 6 points 8 hours ago

I love *nix’s commitment to the bit on the core abstractions.

[–] jaybone@lemmy.zip 7 points 9 hours ago (1 children)

I’m aware of /proc but usually use lsof to find open fd’s for a process.

Is one better than the other?

[–] ozymandias117@lemmy.world 12 points 9 hours ago
[–] otacon239@lemmy.world 24 points 12 hours ago (3 children)

Okay, this is legitimately cool as heck. This finally helps me wrap my head around the “everything is a file” concept in Linux. Of course it can just copy the executable to memory for later reference. That’s how the system would not completely have a meltdown when you do live updates.

Excellent share!

[–] diaphragmwp@discuss.tchncs.de 2 points 39 minutes ago

Wait until you see the Plan 9 API

[–] HiddenLayer555@lemmy.ml 10 points 6 hours ago* (last edited 6 hours ago) (1 children)

I bet this is done with inodes. Deleted files aren't truely deleted until nothing has it open and its inode gets dropped. Like ARC for files.

You can also do interesting things like overwrite a "file" (as in a specific filesystem path) with new contents while keeping anything that already has the file open on the old contents by unlinking the old inode to the path and writing the new contents under a new inode. I believe mv does this. The kind of lesser known feature that probably strikes a good balance between preventing super annoying silent errors/corruption and causing them.

Relevant Kevin Fang video

[–] AlteredEgo@lemmy.ml 1 points 1 hour ago (1 children)

Thanks for explaining, I was wondering about that.

Wait, is that why renaming or moving files on android takes forever?

[–] diaphragmwp@discuss.tchncs.de 1 points 37 minutes ago

No, that's because Android. It's also overlaying all filesystems to enforce stupid rules, like no files named "CON" and no files named the same in a different case (like in DOS).

[–] atzanteol@sh.itjust.works 36 points 11 hours ago

It's a bit more interesting than that...

Linux, unlike Windows, will let you delete a file that is actively in use. It removes the reference on the file system but the contents of the file won't be deleted until all file pointers to it close. In fact it will still be seen as taking up disk space until it's garbage collected (deleting a large file that's in use can be frustrating).

So the file is actually still available to that running process. If you replace it with a new executable and run that then you get the new version.

[–] tapdattl@lemmy.world 32 points 14 hours ago (1 children)

Julia Evans has such great and accessible content, they're awesome

[–] bruh@nord.pub 5 points 12 hours ago (1 children)
[–] rjb@lemmy.ml 23 points 12 hours ago (1 children)
[–] bruh@nord.pub 8 points 12 hours ago

thanks, it's got really hard nowdays to find quality content.

[–] jaybone@lemmy.zip 3 points 9 hours ago (1 children)

I seem to recall in an Operating Systems class we wrote a kernel module and communicated with it through the proc interface?

[–] white_nrdy@programming.dev 4 points 8 hours ago (1 children)

I may have been through "SysFS" as well? In /sys/class you can setup char dev IO with a kernel module (and more). Very helpful for userspace <-> kernel communication (like DMA drivers for userspace applications)

[–] jaybone@lemmy.zip 4 points 8 hours ago

Hmm yeah maybe it was /sys, it’s been so long I can’t remember.

I seem to recall echoing into a file to set some value which we then checked the value of in the kernel module code. It was just a hello world type of thing for a college class.

[–] Jankatarch@lemmy.world 4 points 10 hours ago

I am saving this, both for the post AND for the comments.

[–] Thwompthwomp@lemmy.world 14 points 13 hours ago (1 children)

This is awesome, and I really no no idea about this!

[–] kamenlady@lemmy.world 4 points 13 hours ago (2 children)

I no no idea you liked this, nice

load more comments (2 replies)
[–] luthis@lemmy.nz 4 points 10 hours ago (1 children)

We need the whole set of these in one post

[–] some_kind_of_guy@lemmy.world 2 points 6 hours ago (1 children)
[–] luthis@lemmy.nz 1 points 1 hour ago

Wait, is there not?

[–] naught101@lemmy.world 2 points 9 hours ago

Damn, I really could have made a lot of use of this over the last 20+ years.. Thanks for sharing!

[–] spittingimage@lemmy.world 6 points 12 hours ago (1 children)
[–] rockSlayer@lemmy.blahaj.zone 7 points 13 hours ago (3 children)

I know what a symlink is, but what is a magic symlink?

[–] Redjard@reddthat.com 3 points 5 hours ago

Also known as zombie files. If you are unlucky they can take up all space on a drive, or even tmpfs (so your ram) and you can't easily find them. At least until you end the right process or restart.
Had that happen once and had to write my own script to trace it to the log of an open terminal emulator tab that had billions of lines.

[–] zarkanian@sh.itjust.works 19 points 13 hours ago (1 children)

A symlink that has been blessed by Richard Stallman.

[–] some_kind_of_guy@lemmy.world 2 points 4 hours ago* (last edited 4 hours ago) (1 children)

Richard Stallman as St. IGNUcius

"Now that's a name I haven't heard in a long time" -Saint IGNUcius

[–] Shadow@lemmy.ca 7 points 13 hours ago (7 children)

If you delete a file that's still open by the app, the link in proc will still exist and you can copy the file back out of proc.

load more comments (7 replies)
[–] provectus@lemmy.ml 2 points 10 hours ago* (last edited 10 hours ago) (1 children)

Did you know openBSD does not have this folder? I think the BSD's do not use /proc. I do not know why though.

[–] SlurpingPus@lemmy.world 1 points 57 minutes ago* (last edited 44 minutes ago)

That raises the question of how their ps, top, lsof and such work, since afaik in Linux they read from /proc.

P.S. Looks like BSDs tug at the kernel via syscalls, namely sysctl and also the ‘kvm interface’ in the case of MacOS (not sure what ‘kvm’ thing is meant here). Seems vaguely reasonable, since procfs also queries the kernel for the info, so about the same resources would be used, perhaps even with the overhead of filesystem traversal and string-numbers conversion.

[–] pelya@lemmy.world 5 points 13 hours ago (8 children)

Do you know how to build portable executables?

configure --prefix=/proc/self/pwd

It even works in .so files and libtool.

[–] ozymandias117@lemmy.world 2 points 8 hours ago

I would generally just set the RPATH to $ORIGIN in the ELF file

load more comments (7 replies)
[–] lyralycan@sh.itjust.works 5 points 13 hours ago* (last edited 13 hours ago) (1 children)

Great tips! Although if i may 🤓 just a little for the top right, it works because what you deleted isn't the binary, it's the pointer that points to the binary's location. The data is still exactly as it was before "deletion"; the symlink is simply a copy of the original pointer's info; and I'm speculating that the existence of any pointer prevents the system from recycling those addressed bits.

load more comments (1 replies)
load more comments
view more: next ›