Manage Files on Linux
Linux uses a unified directory tree, meaning every partition, removable disk, network file share, other storage device is accessible as a directory in a single directory tree (or filesystem).
- this filesystem is structured
- some directories have a specific purpose
- all starts at the root directory
/
User Files vs. System Files
System files are files that control how the computer operates.
- includes:
- system startup scripts
- program files
- both binary files and scripts
- program support files
- e.g., fonts and icons
- configuration files
- define how the system works
- configuration files for server services and other daemons
- data storage for system programs
- system log files
- system files are normally owned by
root- to restrict ordinary users from accessing
Filesystem Hierarchy Standard (FHS)
Filesystem Hierarchy Standard (FHS) is a system of standardization for Linux system files.
- some Unix-like OSs also follow FHS
- FHS distinguishes two kinds of files:
- Sharable files
- are files that may be reasonable shared between computers
- e.g., user data files and program binary files
- Unsharable files
- contain system-specific information
- e.g., configuration files
- Sharable files
- FHS also distinguishes between:
- Static files
- doesn’t change except through direct intervention by the system administrator
- e.g., program executables
- Variable files
- files that may change without direct intervention by system administrator
- may change by:
- users
- automated scripts
- servers
- e.g., home directories
- Static files
| Shareable | Unshareable | |
|---|---|---|
| Static | /usr, /opt | /etc, /root |
| Variable | /home, /var/mail | /var/run, /var/lock |
- Find FHS web page at linuxfoundation.org/collaborate/workgroups/lsb/fhs
Important Directories
| Directory | Kind | Purpose |
|---|---|---|
/ | System | Root directory. All files appear in this directory or subdirectories of it. |
/etc | System | Holds system configuration files |
/boot | System | Holds important boot files (e.g., Linux kernel, initial RAM disk, boot loader config files) |
/bin | System | Holds program files that are critical for normal operation and that ordinary users may run. |
/sbin | System | Holds program files that are critical for normal operation and that ordinary users seldom run. |
/lib | System | Holds libraries—code used by many other programs—that are critical for basic system operation. |
/usr | System | Holds programs and data used in normal system operation but that are not critical for a bare bones boot of the system. Split into subdirectories that mirror part of the root organization (i.e., /user/bin, /usr/sbin, /usr/lib, etc.) |
/home | User | Hold’s users’ home directories. |
/root | System | The root user’s home directory. |
/var | System | Holds miscellaneous transient files (e.g., log files, print spool files)./var/tmp holds temporary files, but they should not be deleted upon computer reboot. |
/tmp | User | Holds temporary files. May be deleted when the computer reboots. |
/mnt | User | The traditional mount point for removable media; sometimes split into subdirectories for each mounted filesystem. |
/media | User | The new mount point for removable media; typically split into subdirectories for each mounted filesystem. |
/dev | System | Holds device files, which provide low-level access to hardware. |
/run | System | Information about the running system. |