ubuntu, updated

Everything is a file

The core Linux idea behind disks, devices, settings and processes, plus links, file types and why config is just text.

The idea

On Linux almost everything shows up as a file in one big folder tree that starts at /. A disk, a running process, a kernel setting, a network socket: you can find them as paths and read or write them with the same tools you use for text files.

There are no drive letters. A second disk is not D:, it is “mounted” into a folder, for example /data. See How disks, partitions and volumes fit together.

Examples

PathWhat it is
/dev/sda, /dev/nvme0n1A whole disk
/dev/sda1The first partition on that disk
/dev/nullA black hole: everything written here disappears
/dev/zero, /dev/urandomEndless zeros / random bytes
/proc/cpuinfo, /proc/meminfoCPU and memory info, generated live by the kernel
/proc/1234/Everything about the process with PID 1234
/sys/class/net/Your network interfaces
/etc/hostnameThe server name, as plain text
cat /proc/meminfo | head -3      # read memory info like a text file
cat /sys/class/net/*/address     # MAC addresses of all interfaces

Why it matters for admins

File types

The first character of ls -l tells you the type:

CharTypeExample
-Regular file/etc/hosts
dDirectory/etc
lSymbolic link/etc/resolv.conf
bBlock device (disk)/dev/sda
cCharacter device/dev/tty
sSocket/run/systemd/journal/socket
pNamed piperarely seen

file /some/path tells you what a file really is, no matter its name. Linux does not care about file extensions.

Symbolic link (symlink)Hard link
Createln -s TARGET LINKNAMEln TARGET LINKNAME
Points toa path (like a shortcut)the same data on disk
Target deletedlink breaksdata stays until the last link is gone
Across disksyesno

You will mostly see symlinks, for example /etc/nginx/sites-enabled/ links to files in sites-available/. ls -l shows where a symlink points; readlink -f PATH shows the final target.

Hidden files

Files starting with a dot (.bashrc, .ssh/) are hidden. ls -a shows them. That is the whole mechanism, there is no hidden attribute.

§ home
~/knubertus/home/
1,1 Top