# 04-E.12: Linux Directory Structure

EXAM OBJECTIVES COVERED
1.4 Given a scenario, manage storage in a Linux environment.

## Files

In Linux, everything is a file. There are some special types of files, which we will talk about, but they are all files.

The image to the right shows what the following table is referring to. The very first character on the output line is a dash and this will be the character that tells us what type of file we are dealing with. This image shows this first character is either "directory" or "file," but as we shall see there are several other file types.

So, the following list outlines: 1) the character that will show up in the first column for the various file types 2) what it is called and 3) a brief description of that file type. We will cover this in much greater detail in a later section.

-   Ordinary or Regular File - contain text, are executable programs or are data files used or created by the system
d   Directory - special files that store both other ordinary and special files in an organized manner
c   Character special file - device files that communicates by sending and receiving single characters
b   Block special file - device files that communicates by sending entire blocks of data
l   Symbolic link - a reference that points to another file on the system
p   Named pipe - a file that is used by two process to communicate with each other
s   Socket - a file that connects the output of one process to the input of another process, thereby allowing the two processes to communicate

Linux happens to provide a file command that basically helps you determine what type of file you are looking at. Here are some simple examples of the file command - see the man page for additional options.

pbmac@pbmac-server $file /home/pbmac /home/pbmac: directory pbmac@pbmac-server$ file /etc/passwd
/etc/passwd: ASCII text

pbmac@pbmac-server $file vmlinuz vmlinuz: symbolic link to boot/vmlinuz-4.15.0-91-generic pbmac@pbmac-server$ file my-pipe
my-pipe: fifo (named pipe)

### File Naming Rules

Each file name must be unique within the directory where it exists. File naming guidelines are as follows:

• A file name can be up to 255 characters long and can contain letters, numbers, and underscores.
• The operating system is case-sensitive, which means it distinguishes between uppercase and lowercase letters in file names. Therefore, FILEA, FiLea, and filea are three distinct file names, even if they reside in the same directory.
• File names should be as descriptive and meaningful as possible.
• Directories follow the same naming conventions as files.
• Certain characters have special meaning to the operating system. Avoid using these characters when you are naming files. These characters include the following:
\ " ' * ; - ? [ ] ( ) ~ ! \$ { } &lt > # @ & | space tab newline
• File names may NOT contain: a NULL character, or a / (forward slash).
• A file may not be named . or .. as these are reserved names.
• A file name is hidden from a normal directory listing if it begins with a dot (.). When the ls command is entered with the -a flag, the hidden files are listed along with regular files and directories.