You can read up on this on for instance wikipedia. An excerpt:
The Filesystem Hierarchy Standard (FHS) defines the main directories and their contents in Linux operating systems. For the most part, it is a formalization and extension of the traditional BSD filesystem hierarchy.
The FHS is maintained by the Linux Foundation, a non-profit organization consisting of major software and hardware vendors, such as HP, Red Hat, IBM and Dell.
The current version is 3.0, released on June 3, 2015.
A visual representation with a short description:
Basically Linux has divided the directory structure based on the function of what is needed to make the system as secure as possible with the minimum amount of permissions needed. Otherwise someone is bound to have to do alot of avoidable work.
Remember that Unix and Linux where made as multi-user systems and Windows was created for a single user. Everything else can be explained from that idea. You can explain every directory when thinking about it being multi-user and security.
3 examples:
You will see that files and directories that are admin only are gathered in the same directory: the s in /sbin
and /usr/sbin
and /usr/local/sbin
stands for system. A normal user can not even start programs that are in there. Files a normal user can start are in /bin, /usr/bin, /usr/local/bin based on where it most logically should reside. But if they are admin only they should go to the s
version of that directory.
There is a famous utility called fuser
. You can kill processes with it. If a normal user could use this (s)he would be able to kill your session.
The same goes for /home
: /home/user1 is property of user1. /home/user2 is property of user2. user2 has no business doing stuff in user1's home (and the other way around is also true: user1 has no business doing stuff in user2's home). If all the files would be in /home with no username underneath it you would have to give permissions to every file and asses if someone is allowed to write/remove those files. A nightmare if you have tens of users.
Addition regarding libraries.
/lib/
, /usr/lib/
, and /usr/local/lib/
are the original locations, from before multilib
systems existed and the exist to prevent breaking things. /usr/lib32
, /usr/lib/64
, /usr/local/lib32/
, /usr/local/lib64/
are 32-/64-bit multilib inventions.
It is not a static concept by any means. Other Linux flavours made tweaks to this lay-out. For instance; currently you will see debian and Ubuntu changing a lot in the lay-out of the FHS since SSD is better off with read only files. There is a movement towards a new lay-out where files are split in to a 'read only' and a 'writable' directory/group so we can have a root partition that can be mounted read only (partition for a ssd) and writable (sata hdd).
The new directory that is used for this (not in the image) is /run/
.
Linux is not all that different to MS-Windows:
Gnu/Linux an improved and Free Unix. MS-Windows is based on MS-Dos that is a poor clone of CPM that was inspired by Unix.
There is one main difference: Gnu/Linux and all Unixes have one root, one unified hierarchy, and therefore no drive letters. MS-Windows, DOS and CPM have multiple hierarchies, one for each drive/partition, they are given letters (e.g. c:
). On Gnu/Linux home will be mounted on /home, it will be there no matter if it is on the same partition, a separate partition or a network share. The advantage of this approach is that the name of files is not dependant on the location of the storage device. The advantage of the Ms-Windows, dos, cpm way is that is was easier for the operating system programmers when they wrote the operating system.
Sub-trees (from other partition, disks or network share etc. ) can be grafted on, but there is one tree per computer. You can even share sub-trees between computers using network file shares, but they are sub-trees not new trees.
Type mount -l
on a command line to see all mounts. Note this includes a few special mounts that have no backing store. Also df -h
to get usage info.
Example from my system:
#how full are my filesystems.
df -h --print-type
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda5 ext4 20G 9.7G 8.7G 53% /
tmpfs tmpfs 1.5G 0 1.5G 0% /lib/init/rw
udev tmpfs 1.5G 284K 1.5G 1% /dev
tmpfs tmpfs 1.5G 4.0K 1.5G 1% /dev/shm
/dev/sda6 ext4 87G 64G 18G 79% /home
/dev/sdb2 ext4 230G 85G 133G 39% /media/extra
#detailed info on what is mounted, but no size or usage info.
mount -l
/dev/sda5 on / type ext4 (rw,dirsync,errors=remount-ro,barrier=1,data=journal,auto_da_alloc,journal_checksum) [debian]
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sda6 on /home type ext4 (rw,dirsync,errors=remount-ro,barrier=1,data=journal,auto_da_alloc,journal_checksum) [debian-home]
fusectl on /sys/fs/fuse/connections type fusectl (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
/dev/sdb2 on /media/extra type ext4 (rw,nosuid,nodev,uhelper=udisks) [extra]
- The root file-system
/
[equivelent to c:
] is on primary hard-disk partition.
- On
/lib/init/rw
we have a temporary ram based file system. (probably used by init, process 1, probably best it ignore it)
- on
/proc
we have the proc file-system. This is magic, it is a dynamic file-system, it can tell you lots of cool stuff about you processes/system.
- on
/sys
we have the sys file-system. (see what I said about /proc
)
- on
/dev
we have udev. udev manages /dev
. /dev
is a where lots of magic lives, lots of things that you may not think of as files live there: partitions, audio/video input output, keyboard, mouse, a black-hole (/dev/null
), a source of nothing (/dev/zero
), etc.
- on
/home
is another disk partition. This is where users directories are. [Equivalent to ?:\User
on modern Microsoft os, where ? may be C, or something else].
- on
/media/extra
is an external hard-disk. /media
is a place that external drives get mounted on automatically. In /media
is also a directories /media/cdrom
and /media/cdrom0
the first a reference to the other. They are empty directories, but if I put in a cdrom. Then the cd appears here. [ Equivalent to random-letter-of-the-day:\
]
more examples:
#what swap have I got, and what is being used.
/sbin/swapon -s
Filename Type Size Used Priority
/dev/sda7 partition 4095992 0 -1
#what disks and partitions have I got.
ls -l /dev/disk/by-path/*
lrwxrwxrwx 1 root root 9 Jul 15 22:39 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:1.1:1.0-scsi-0:0:0:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:1.1:1.0-scsi-0:0:0:0-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 9 Jul 15 22:39 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root 10 Jul 15 22:39 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part7 -> ../../sda7
lrwxrwxrwx 1 root root 9 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-1:0:0:0 -> ../../sr0
/dev
is the directory that raw devices live in. /dev/sd*
are disk partitions. /dev/sda
is primary hard disk /dev/sdb
is secondary hard disk in my case an external one. /dev/sd?1
is first partition of a disk. 1,2,3,4 are primary partitions, 5,6,7,etc are secondary partitions.
Best Answer
Ubuntu does not use drive letters; it sees all of its available space as one large tree. It lists your Windows drive (which is called "C:" in Windows) as one of its "Devices", as you mention, but that is just a matter of convenience: in Ubuntu terms that is probably a folder called
/media/long-complicated-drive-name/
.The fact that you can see more files in Ubuntu than in Windows is more like a Windows trick: under Ubuntu you will see all files and directories, whereas Windows hides these from you.
The
boot
,etc
,dev
,root
,run
etc. are system folders where you shouldn't store anything, and in most cases, the system won't even let you. Feel free to organize your own files in the/home/username
folder. That one is comparable with the folder called "username" under Windows. Ubuntu does not care how and where you store things in/home/username
, except for personal settings which are typically in folders starting with a ".".From the Windows perspective, whether your Ubuntu system is stored in D: or J:, or somewhere else, is impossible to tell without more information.