A file is a chunk of data that the kernel (or you) can manipulate in various ways. Files are stored in directories (``folders'' under MacOS and Windows). Documents are often ``text files,'' programs can be either ``executable binary files'' (.exe files in DOS) or ``scripts'' (DOS .bat files), several files may be archived and compressed as a single file, and so on. In GNU/Linux, everything18 is a file from the kernel's point of view. Almost all processes function by reading from and writing to files, and processes communicate using files called ``pipes'' and ``sockets''. Files are stored in a treelike structure called a filesystem. The root of the tree is the root directory, called /. In the root directory are the ``core'' system directories,
A GNU/Linux filesystem is built by mounting filesystems that reside on a storage medium (usually the hard drive, but possibly a floppy or CD). The directory /mnt contains empty directories that serve as mount points for auxiliary filesystems. To view the contents of a floppy disk under GNU/Linux, you must first mount the disk's filesystem on an empty directory (such as /mnt/floppy). You may not simply insert and remove floppies or CDs from a GNU/Linux system. The /proc directory is used by the kernel for bookkeeping of running processes, and is useful as a tool for determining what devices the kernel knows about, or how much memory is free. This directory resides solely in RAM, not on the hard drive.
Users' home directories reside in /home. The /usr directory contains most of the software and data (word processors, web browsers, games, ...), and finally, /var contains files whose content changes frequently (``variable files''), such as mail, printer, and news spools, name server databases, and system log files.
If you try to modify (or sometimes merely view) certain files or directories, you may get the message permission denied. This means exactly what it says; you do not have write (or read) permission on the file in question. If you (as an ordinary user) try to remove a system file, you should receive this message. (Do not experiment like this as root.)
Every file in the root filesystem has a unique name, called its full pathname. The text file that was processed to make this document is called
Filenames are rather different in GNU/Linux than in Windows, though they are not unrelated. First, GNU/Linux filenames should consist only of letters, numbers, periods, dashes, and underscores. Most punctuation characters (including spaces) have special meanings to the shell, and should be avoided in filenames. However, there is no practical limit on lengths of filenames (certainly 256 characters is allowable), and there is no limit on the length of a filename extension. Second, GNU/Linux (like all Unices) is case sensitive; intro.tex, Intro.tex, and intro.TEX are different filenames. Finally, GNU/Linux itself does not look at filename extensions; it does not automatically treat a .txt file differently from an .html file. There are a few naming conventions (needed by application programs), but mostly you're free to use whatever filenames you like.
Permissions on ordinary files and directories work
differently, see Table 1. The following operations
(when permitted) may be performed with the command shown: List the
contents of a directory ( ls); view the contents of a file
cat <filename> or
less <filename>); remove a
rm <filename>); remove all the files in a directory
rm -f *); removing the entire contents of a directory,
including all subdirectories (
rm -Rf *); move to any point
in the filesystem (
cd <target directory>). If a result of
a command is forbidden, you will receive a permission denied
message for the forbidden portion. For example, if you type ls
-aR /, you get a list of all files that reside in directories in
which you have both read and execute permissions, and you will get a
permission denied message for all directories in which you do
not have both permissions.
GNU/Linux uses both RAM and the hard drive for data storage. RAM is faster (by a few orders of magnitude), but the hard drive holds more (by a few orders of magnitude) and retains information even when the power is turned off. GNU/Linux keeps records of running processes, recently modified user files, and other filesystem information in RAM. Because of this, You must never turn the power off without shutting down. Failure to shut down properly may result in lost data and corruption of the filesystem. Shutting down in described in Section 5.1.