Skip to main content
Engineering LibreTexts

04-E.12: Linux Directory Structure

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    1.4 Given a scenario, manage storage in a Linux environment.


    In Linux, everything is a file. There are some special types of files, which we will talk about, but they are all files. We have looked at file permissions before. The very first position in a file's permission tells us what type of file it is.

    The first position is:
    A dash, this is an ordinary file or a hard link
    The letter d, this file is a directory
    The letter c, a special character file
    The letter b, a block special file
    The letter l, this is a symbolic link
    The named pipe and the socket are more infrequent.

    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
    -   Hard Link - an additional name for an existing file
    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.

    Adapted from:
    "A beginner's guide to Linux permissions " by Bryant Son, is licensed under CC BY-SA 4.0

    04-E.12: Linux Directory Structure is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?