Command Line Basics Part 2: Unix File System
In the most recent post in this series I talked about the commands you use to move around the file system. Now I’ll look at some of the places you might want to go.
Linux (and other Unix-like operating systems) inherited their file system layout from a long history going back to the original Unix incarnations in the 1970s. Over time various versions changed where things were located. The Filesystem Hierarchy Standard is an attempt to standardize this. It probably doesn’t cover all Linux/Unix installations perfectly, but it’s a fairly good guide of where stuff is in a modern installation.
The most common place you’ll visit when administering a system is the /etc directory tree. That’s where the configuration files for applications installed on the system reside. So if you need to change an application setting, you’ll go to that application’s configuration directory under /etc. For instance, if you have a web server, the configuation files will be under /etc/apache2. Here’s a listing of the contents of that directory:
The right column in this display is the name of the file or directory. The first character is “-” for files and “d” for subdirectories. apache2.conf has basic setup for the apache web server. The directories mods-available and mods-enabled are used to control what optional software modules are set up to be used with the web servers.
Another important configuration on a system is the configuration of Secure SHell (/etc/ssh):
Modern Linux kernels have a window into the functioning of the kernel built into the file system, under the /proc directory. It’s filled with virtual files that don’t really exist on disk, but the contents of those files are populated by function calls to the kernel. The file /proc/cpuinfo, for instance, contains the kernel’s information about the processor (the “more” command just prints the contents of a file to the command line display):
(I’ve only listed part of the output here). /proc/meminfo is useful too; it tells you information about virtual and physical RAM.
Finally, data for installed applications lives in the /var file system. The default location of the directory where the files for the apache web server live is /var/WWW. So to edit files on a new web server, you’d go to the /var/WWW and set up your files there.
So this is a very basic overview. Most of the files you’ll need to get at as an admin will be in /etc or /var. Next time, I’ll talk about options for editing files.
Craig Steffen cut his command-line teeth on MS-DOS 2.11 round about 1986 or 87; his first Unix-like OS was NeXT-Step on NeXT computers in 1991. He used Solaris, Irix, and increasingly Linux in graduate school, and runs mostly (Ubuntu) Linux nowadays. He lives in appalachia but oddly works for a mid-west University. In his spare time he mucks around with his vintage VW and occasionally flies small airplanes. You can see more at his blog and on twitter.