Hi, *nix newbie here. I'm struggling with understanding how my Ubuntu's filesystem works and what general practices various applications follow when they install to my Ubuntu instance. I'm currently reading the ldconfig man page and feeling pretty lost. Any good guides or resources for understanding how filesystems and links work?Thanks!
[+] [-] digikata|9 years ago|reply
For file placement you might start here: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Though I'd caution that it's not a strict standard, and you find that many linux distributions vary from it in particular ways.
For the implementation of file systems on Unix/Linux/Ubuntu, I'd say start at understanding inodes: (this link is just the first I found that seems like a reasonably short overview from my standpoint) https://www.cs.nmsu.edu/~pfeiffer/classes/474/notes/inodefs....
There are a world of different implementations when you get to the details, but the Linux kernel builds or reuses this core idea of inodes into many specific different filesystems. From there there is a lot of info, but the Linux VFS layer handles many common functions of of filesystems in Linux (even if you're system is using ext4 or btrfs, etc specifically). So the Linus Kernel vfs docs may be interesting if you're looking to go even deeper.
[+] [-] loeg|9 years ago|reply
And if you're at all interested in BSD file layout, there's hier(7): https://www.freebsd.org/cgi/man.cgi?hier(7) .
Re: Linux inodes (FreeBSD calls them "vnodes," short for virtual inodes, to distinguish the generic API from filesystem-specific per-file data, which it calls inodes), there's vnode(9) and VFS(9) to get started:
https://www.freebsd.org/cgi/man.cgi?vnode(9)
https://www.freebsd.org/cgi/man.cgi?VFS(9)
[+] [-] nomadlogic|9 years ago|reply
https://www.amazon.com/Design-Implementation-FreeBSD-Operati...
[+] [-] vram22|9 years ago|reply
[+] [-] dekhn|9 years ago|reply
[+] [-] crossbowerbt|9 years ago|reply
Ah, it's also free ;)
From the the haiku project website: https://www.haiku-os.org/legacy-docs/practical-file-system-d...
[+] [-] batbomb|9 years ago|reply
[+] [-] twsted|9 years ago|reply
[+] [-] ohstopitu|9 years ago|reply
I'd recommend anyone to do the same!
It does not have to be anything magical...just try to build a basic program that can emulate a file system (read files, write files, list files, have links, edit files, edit names, delete files, copy etc.)
The aim here is NOT to have a file system that you'll use daily, but to understand the concepts by programming them.
While this book goes into some details about it [0], I "understood" how it all worked together by building one.
FYI - I think the book focuses on C when giving examples, but if you know the concepts, it can be built in any language (Go, Java etc.)
[0] - https://www.amazon.com/Operating-System-Concepts-Abraham-Sil...
[+] [-] wkz|9 years ago|reply
I have not looked at the filesystem implementation, but since it is designed as a teaching OS, my guess is that it should be a good entry point.
https://github.com/mit-pdos/xv6-public/blob/master/fs.c
[+] [-] d0mine|9 years ago|reply
Run:
It describes the file system hierarchy.[+] [-] mgpela|9 years ago|reply
[+] [-] SleuthKid|9 years ago|reply
Brian Carrier File System Forensic Analysis https://g.co/kgs/lv7gVN
[+] [-] anth1y|9 years ago|reply
From the horses mouth take a look at ext4 on ubuntu https://help.ubuntu.com/community/LinuxFilesystemsExplained
Then a 10,000 mile view, I'd take a look at UNIX and Linux https://www.amazon.com/UNIX-Linux-System-Administration-Hand...
There are more books I could list and papers on FileSystems. I will leave you with three particular books that have guided my career
If you want to look solely at Ubuntu. The Ubuntu Server book https://www.amazon.com/Official-Ubuntu-Server-Book-3rd/dp/01...
Unix Made Easy - https://www.amazon.com/UNIX-Made-Easy-John-Muster/dp/0072193...
Hope this helps
[+] [-] nlg|9 years ago|reply
https://www.amazon.com/Linux-Programming-Interface-System-Ha...
[+] [-] detaro|9 years ago|reply
[+] [-] mgpela|9 years ago|reply
[+] [-] vram22|9 years ago|reply
[1] Why I say "take with a pinch of salt" is because this is based on what I learned a while ago about Unix file systems (and some of the terms are also related to DOS and Windows), and some enhanced file systems have come out after that, so some of the terms I mention may be out of date (but likely not, or not many).
Look up these words and terms (not given in any logical order):
(Unix) inode, directory entry, file system, disk partition, physical partition, logical partition, fdisk, cfdisk, boot sector, boot record, master boot record, GRUB, LILO, boot loader, ext2, ext3, ext4, file system types, journaling file system, fsck, fsdb, superblocks, disk 'cylinders, heads, tracks and sectors', disk block size, buffer cache, logical volumes, disk spanning, disk striping, RAID, disk formatting, block device, character device, device file, device driver, ...
You will get many of those terms explained in the resources that others in this thread have mentioned. But this can be a fast way of getting an overview of many of these terms via Wikipedia articles or other pages about them, which may even motivate you to read the longer explanations.
If you are a programmer and know some C, you can also look up functions / system calls / man pages like stat, dirent, opendir, readdir, etc., and have some fun getting (and for some things, setting) the contents of directories programmatically, getting file metadata like file size, type, times (access, modification, etc., owner and group, permissions for owner, group, other, etc.)
Edited to add a few more terms.
[+] [-] vram22|9 years ago|reply
[+] [-] tbirrell|9 years ago|reply
A couple things for you which may be obvious, but a good place to start nonetheless:
/ - This is Root. Most of your system files are in this directory.
/home/username/ - This is your home directory, a common abbreviation is "~/" (tilde). If you are a windows user, this is the equivalent of the file system you are used to using. In this directory are also many dot files (.ssh/, .local/, etc). these are (usually hidden) system files that are specific to your user. Generally, there are defaults in / (root) and these files customize them for your user only.
Knowing these two things and a handful of basic commands will allow you to get started. Look into the commands 'cd', 'pwd', 'ls', 'sudo', 'touch', 'mkdir'.
[+] [-] slau|9 years ago|reply
In addition, you most typically wouldn't find the defaults in `/`, for the reason listed above. The default files copied over by the `useradd` (or `adduser`) command are usually sourced from `/etc/skel`.
To answer the OPs question, there are a number of differences in the way different distributions choose to implement their directory structure. That, and the default packages they ship with are the whole reason they exist. My best recommendation is to pick a distro, and learn the generalities you can from it.
Most configurations are found in `/etc/`. Most defaults can be found in `/etc/default`. `/opt` is usually after market software, or placed there to not conflict with the base system (for example, the Fedora/CentOS SCL installs newer toolsets, such as GCC/LD/Make into `/opt, though loads of proprietary software also installs there to not have to bother with proper packaging). `/usr` will be where all the system-provided tools and documentation will live. `/var` is used by programs and daemons to store their state.
Any directory can live on a different partition or disk. Use the `df -h` command to get an overview of your mount points. Also, unlike Windows, a disk or partition doesn't live next to all the others. They can all be interleaved into the root directory structure. Just because `/` is only 5GB doesn't mean you can't have a 2TB home directory or 30GB of programs and librairies installed.
[+] [-] alexvoda|9 years ago|reply
If you are interested in alternatives, you can have a look at GoboLinux: https://gobolinux.org/?page=at_a_glance
Or have a look at NixOS, which has a different take: https://nixos.org/nixos/about.html http://funloop.org/post/2015-08-01-why-i-use-nixos.html
[+] [-] marios|9 years ago|reply
[+] [-] jrowley|9 years ago|reply
https://github.com/libfuse/libfuse
[+] [-] crossbowerbt|9 years ago|reply
[+] [-] bogomipz|9 years ago|reply
"UNIX Filesystems: Evolution, Design, and Implementation 1st Edition" by by Steve D. Pate
"Practical File System Design with the Be File System" by Dominic Giampaolo
[+] [-] wenbin|9 years ago|reply
[+] [-] xiphias|9 years ago|reply
[+] [-] stefantalpalaru|9 years ago|reply