THE BIG PICTURE === === ======= ALMOST EVERYTHING YOU NEED TO KNOW ABOUT EVERY FLAVOR OF LINUX!!! (Compiled by R.Sonnenfeld 5/2005) -- I have compiled this from several sources and my own head, but almost all of it can be found (in a more readable format) at 1) 80% of this -- http://openskills.info/seminars/distro/index.htm (A talk by Alessandro Franceschi) 2) The other 20% -- http://www.bb-zone.com/SLGFG/toc.html (The Suse Linux Guide for Geeks) This is not for beginners, but when you are at the stage that you've played w/ Linux and are trying to get the big picture, this will save you a lot of time. In my research group, we run Pebble (a Debian derivative) on our embedded scientific instruments, Gentoo on our data analysis computers and Slackware on our laptops for the field. It wasn't necessarily intentional, but anyway, my students need to know several different distributions. I was delighted to find a presentation that explained the differences between distros that really matter (Mostly networking and boot process.) I - BOOT PROCESS ---------------- After you read this, you'll understand why the two most important configuration files in a linux system are: 1) /etc/lilo.conf or /etc/grub/grub.conf 2) /etc/inittab If you read the documentation about inittab, you will understand how to locate (ultimately!) every other critical configuration file on your system. One obvious and universal one is /etc/fstab. Entire Boot process from power up (Lifted from Suse Linux Guide for Geeks -- Numbering comes from that book) 5.1 The Four Steps of the Booting Process In this section, we discuss nearly everything that goes on from the moment you push the "power on" button until the login: prompt appears. This sequence of events can be roughly divided into four steps: hardware initialization, bootloader/system selection, kernel initialization, and invocation of init. 5.1.1 Hardware initialization Hardware initialization is a PC's normal power-up routine. It usually checks its memory, initializes devices, and powers up its own BIOS and the BIOSes of intelligent adapters, such as SCSI and so on. It then searches for bootable devices, which in most BIOSes can be selected in the BIOS setup. These are usually the floppy disk, hard disks, and, in newer BIOS versions, the CD-ROM. 5.1.2 Bootloader/System selection After this first step, the BIOS loads the boot sector of the first valid boot device and runs this code. The boot sector is the very first sector of this device. It has to contain a loader routine, which either starts up the operating system or presents the user with a selection, such as which OS to start. You can use either LILO or GRUB to boot from a HDD (or a compact flash). (SYSLINUX is for Boot CD's). LILO is more primitive. The LILO MBR needs to be written to the first 1024 cylinders of either of the first two hard drives. GRUB can support more drives and, it appears be written almost anywhere on a single large drive with multiple partitions. If you want to use LILO to boot several different distros, it looks like you ought to make a separate partition called "BOOT" which is quite small and is at beginning of your hard drive. If you are using grub, you don't need to be this careful, and you don't need a special boot partition at all. 5.1.3 Kernel initialization We assume here that you selected Linux as the OS to boot. This means that LILO loads the kernel image into RAM and executes it. Now the Linux kernel takes over the control of the system. It initializes itself, eventually autoprobes devices, initializes detected devices, and, if all this is done, it starts init, the process that parents all other user-level processes of the system. 5.1.4 Invocation of init Now you are at the point where you can choose where to go. The init process reads its configuration file (/etc/inittab) and processes scripts or commands instructed in this file. Boot process and services management -- More about init (Lifted from http://openskills.info/infobox.php?ID=1081) The boot process of Linux on a Intel i386 architecture has steps common in every distro: - A Linux Loader is placed at the first sector read by the bios (The Master Boot Record of an hard disk, or the equivalent of a CDROM) - The kernel is loaded. Newer distributions use a kernel of the 2.6 family, but the 2.4 is still widely deployed. - Init is started and executes various scripts. The Linux Loader (on Intel compatible architectures) is typically Lilo or Grub for hard disk installations (Syslinux is a common choice for booting CDROMs: live or install disks). Configuration files are generally /etc/lilo.conf and /boot/grub/grub.conf here you define: - where to place to Linux Loader (Master Boot Record or boot record of a single partition), - what is the partition where resides the root ( / ) of your system, - the path for the kernel image and for the initrd. It's always possible to define different systems to boot (Linux or other OS) and different kernel versions. The Linux Kernel in every distro is obviously derived from Linus Torvalds' kernel but it can have different version and some variations and non-Linus patches defined and compiled by the distro maintainer. It's always possible to recompile the kernel from the official sources or from the custom source packages of the distro used. Init is the first process launched in every UNIX system: it's config file is ALWAYS /etc/inittab Analyze it and all the script sourced from it and you can entirely reconstruct what happens in the boot process. The logic the distro maintainer has used in the initscripts largely defines the systems' nature and essence. The difference between Linux/Unix dialects is mostly a matter of shell (init)scripts. The Unix System V boot method, based on the rc scripts is used in many Linuxes and defines what startup scripts in /etc/init.d/ activate at the different runlevel. Debian (Pebble / Knoppix) /etc/init.d/rcS - The system initialization script that executes all the "S" symlinked scripts in /etc/rcS.d/ for system initialization. The directory /etc/default/ contains configuration settings (similar to /etc/sysconfig/ of other distros). After the basic initialization, the system enters in the default runlevel (Note: Debian uses 2 as default text networked runlevel, instead of 3, as in various other *nix) executing the services startup scripts in /etc/init.d according to the SysV logic of the /etc/rc#.d/ symlinks. RedHat /etc/rc.d/rc.sysinit Large script, launched directly by init, that sets and executes all the system initialization functions. It sources configuration files in /etc/sysconfig/* where user (and configuration tools) define various system settings /etc/rc.d/functions General purpose functions used by every system script /etc/init.d/* The startup/shutdown scrips of all the system services activated according to the symlinks in the /etc/rc#.d/ directories SlackWare /etc/rc.d/rc.S - System Initialization /etc/rc.d/rc.modules - Kernel modules loading /etc/rc.d/rc.pcmcia, rc.serial ... - Probe and configure various hardware devices /etc/rc.d/rc.sysvinit - Executes the SysV init files according to the chosen runlevel /etc/rc.d/rc.local - Reserved for user's custom boot commands Mandrake /etc/init.d/rc.sysinit Large script, launched directly by init, that sets and executes all the system initialization functions. It sources configuration files in /etc/sysconfig/*) where user (and configuration tools) define various system settings /etc/init.d/functions General purpose functions used by every system script Gentoo /sbin/rc handles everything and does different activities according to the argument given. Gentoo's inittab executes: /sbin/rc sysinit for general system initialization, /sbin/rc boot for further generic boot commands and /sbin/rc default to enter in the default runlevel, executing the usual services scripts in /etc/init.d/. SUSE /etc/init.d/boot First script launched by init, it sources and handles what follows /etc/init.d/boot.* Various boot files for different purposes that are executed according to the logic of S/K symlinks in the /etc/init.d/boot.d/ directory /etc/init.d/boot.local Last file, before entering in the rc phase, reserved for user's custom boot commands /etc/init.d/* The single services startup scripts launched according to selected runlevel (/etc/init.d/rc#.d/ rc symlinks) II - SYSTEM PROCESSES (by R.Sonnenfeld) -------------------------------------- So ... what all is running on your system? ps -A (or e) Shows you EVERYTHING (ps -a shows you only what you own) The process ID is the first # shown. You can kill a process w/ its process ID. You can use "top" to get an ongoing summary of processes. Below is a partial list of the directory /proc. richard@dirac proc $ ls 1 22510 29495 3 6695 6764 7707 7825 7860 7879 906 acpi execdomains kallsyms mtrr sysvipc 1124 25190 29509 4 6738 6765 7709 7827 7869 7880 908 asound fb kcore net tty 149 25205 29510 5452 6739 6777 7715 7831 7870 7881 909 buddyinfo fb0 kmsg partitions uptime 162 25206 29559 6154 6740 6778 7717 7833 7871 7886 952 bus filesystems loadavg pci version Note the #'d directories. Each of them contains detailed info on the process whose ID it is. Thus the directory "1" is all about "init". III - LINUX DIRECTORY STRUCTURE-- -------------------------------------- The location of systems files (binaries, configurations, logs, devices, docs...) are typically a nightmare for a junior operator handling with Unix dialects. There are Unix standards, there's a Filesystem Hierarchy Standard, there's the distro maintainer's choice but, most of all you have tools useful to locate files positions: which, locate, whereis, whatis, apropos, find... In the apparent chaos of nested directories there's still coherence and login: /bin Essential user command binaries (for use by all users) /boot Static files of the boot loader /dev Device files /etc Host-specific system configuration /home User home directories (optional) /lib Essential shared libraries and kernel modules /media Mount point for removeable media /mnt Mount point for a temporarily mounted filesystem /opt Add-on application software packages /root Home directory for the root user (optional) /sbin System binaries /srv Data for services provided by this system /tmp Temporary files /proc Kernel and process information virtual filesystem /var Variable files that change their size /usr Users commands and tools /var/account Process accounting logs (optional) /var/cache Application cache data /var/crash System crash dumps (optional) /var/lib Variable state information /var/lock Lock files /var/log Log files and directories /var/mail User mailbox files (optional) /var/opt Variable data for /opt /var/run Run-time variable data /var/spool Application spool data /var/tmp Temporary files preserved between system reboots /usr/X11R6 X Window System, Version 11 Release 6 (optional) /usr/bin Most user commands /usr/include Directory for standard include files /usr/lib Libraries for programming and packages /usr/local Local hierarchy /usr/sbin Non-essential standard system binaries /usr/share Architecture-independent data /usr/src Source code (optional) Source: http://www.pathname.com/fhs/ IV - LINUX NETWORK CONFIGURATION-- -------------------------------------- The basic commands used in Linux are common to every distro: ifconfig, route, hostname, netstat, arp, mii-tool. Many distro are now including the iproute2 tools with enhanced routing and networking tools, among these the powerful ip and tc commands. Every distro has its own configuration tool that operate on variously defined configuration files. Some of them are common: /etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts, /etc/services, /etc/protocols Some, typically the ones where are defined IP addresses and routes, change. Here are some relevant files for various distro, their syntax may vary according the scripts used to handle them: Distro Configuration Files Conf Tool Debian /etc/network/interfaces - Interfaces and network parameters (Pebble / Knoppix) RedHat /etc/sysconfig/network-scripts/ifcfg-* - Configuration files for each interface. The same file can be found, divided per profile, in /etc/sysconfig/networking/devices/* /etc/sysconfig/network - Hostname, default gateway, general configuration /etc/sysconfig/static-routes - Static routes (if any) redhat-config-network SlackWare /etc/rc.d/rc.inet1 - IP and network parameters /etc/rc.d/rc.inet2 - Network Services configuration netconfig Mandrake /etc/sysconfig/network-scripts/ifcfg-* - Configuration files for each interface. The same file can be found, divided per profile, in /etc/sysconfig/networking/devices/* /etc/sysconfig/network - Hostname, default gateway, general configuration /etc/sysconfig/static-routes - Static routes (if any) drakconnect Gentoo /etc/conf.d/net - Ip network and interfaces parameters netconfig /etc/conf.d/routes - Static routes (but manual may be better_ SUSE /etc/sysconfig/network/ifcfg-* - Configuration files for each interface. /etc/sysconfig/network/config - General network configuration Yast2