this post was submitted on 25 Nov 2023
97 points (95.3% liked)
Linux
48220 readers
701 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
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Ok. Lessee.
Just to quickly explain first off:
01100001
and later it can reliably be read back from the same index as the same value, until it's changed to a different value.)/dev
for the disk along with more files for each of the partitions on the disk. For instance, an external USB hard drive with three partitions might show up as/dev/sda
and the partitions as/dev/sda1
,/dev/sda2
, and/dev/sda3
respectively. (Ok. Technically the things in/dev
are only files in some senses. They're technically "devices". But they have paths like files do and they can be read from and written to like files.)/dev
a file lives on and what filesystem driver is used for that device, themount
command just typed into any bash terminal will tell you. It'll output rows likeon type (...)
. If you read/write a file or list a directory, it'll pick the entry in themount
output that has the longestthat is a prefix of the requested file. The
is the "file"(/device) in/dev
that corresponds to the parition on which that file is encoded. `` is the name of the filesystem driver. So, for instance, if I have an entry/dev/sdb3 on /mnt/pringles type ext4 (...)
and I read a file named/mnt/pringles/apple/unicorn/potato.txt
(and if there are no entries in themount
output with longer paths that are still prefixes of the requested file path), the kernel will ask theext4
filesystem driver to please look at the partition/dev/sdb3
and interpret that partition's contents as a hierarchical filesystem to find and return the contents of the file at the pathapple/unicorn/potato.txt
relative to the root of the filesystem encoded on the/dev/sdb3
partition.tmpfs
store data in RAM only (and RAM isn't intended to be persistent, so you can't expect anything in a tmpfs to last reliably through a reset.) Others likeprocfs
don't look at a disk but make these ephemeral files that basically decide what data to return when read from at the time they're read from. (Files inprocfs
filesystems usually expose data about the Linux system. Like, for instance, what processes are currently running.)Now, the question of where files should go is... kinda unrelated to the above. Files that are system-wide configuration should go in
/etc
. Files that are system-wide executables should generally go in/bin
,/sbin
,/usr/bin
,/usr/sbin
, and/usr/local/bin
. Anything your own user downloads/creates should go in/home/$username
. Etc. More specifics of all this here.It can be useful to make decisions regarding what disk/partition a particular directory like
/home
lives on. But whether/home
is on the same partition with/etc
and/bin
and/var
etc or whether it's on a different partition (and both of these options are quite common), your users' files should go somewhere in/home
.To elucidate a little more, if you decide to put your
/home
on the same partition as/bin
and/etc
and/var
and such, you'll have an entry in yourmount
output like/dev/sda2 on / type ext4
but nothing with a `` of/home
. If you decide to put/home
on a separate partition, you'll have your/dev/sda2 on / type ext4
entry plus another entry like/dev/sda3 on /home type ext4
.So which partition does a file go on when you write a file to
/home/keenflame/document.txt
? Well, in the first case, it'd be on the partition Linux calls/dev/sda2
. In the second case it would be written to the partition that Linux calls/dev/sda3
.