SlideShare a Scribd company logo
Linux Directory Structure

        Kevin B. O’Brien
 Washtenaw Linux Users Group
    http://www.lugwash.org
General Notes
●   Linux derives from Unix and is designed
    to be multi-user
●   This explains some otherwise puzzling
    choices
●   This may have something to do with
    Fedora proposing to change this
    Directory Structure
Drives 1
●   Linux derives from Unix
●   Different from Windows
●   Windows starts with drives, which are
    explicit
    –   C:
    –   D:
Drives 2
●   Linux does not make drives explicit.
●   You can have one physical drive, several
    physical drives, partition the drives into multiple
    partitions, and normally you won’t be aware of
    it.
●   In a file manager, you won’t see drives, just
    directories
●   But if you look in fstab, you will see things like
    hda1, hda2, sda1, sda2. These are logical
    drives (either physical or from partitioning)
Root
●   In Windows, every drive has its own root
    –   C: is the root of the C drive
●   In Linux, there is only one root, no matter
    how many drives you may have
    –   In Linux, / is the root
●   Root is ambiguous in one respect, since it
    can refer to the top of the file structure,
    and is also the name of the Administrator-
    type account in Linux.
Root 2
●   For our purposes, we will refer to root as
    the top of the file structure in this
    presentation.
Comparison
       Linux                     Windows


         /home                       C:

                    Disk
       /home/data   Partitions       D:
   /
root
           /var                      E:

          •/boot
           •/bin                     F:
           •etc.
Watch out for...
●   Windows uses a backslash for
    everything
●   Linux uses a forward slash for
    everything
●   In Windows, the logical drive (e.g. C:) is
    an important part of the directory
    structure
●   In Linux, logical drives don't mean
    much. You can even mount a separate
    physical drive under a directory that is
    on another drive.
Watch out for 2
●   In Windows, case does not matter. The
    C:Windows directory is the same as
    the
    c:windows directory.
●   In Linux, everything is case sensitive.
    The convention in Linux is to use lower
    case for most things, but the important
    thing to remember is that /usr/bin is not
    the same thing as /USR/BIN.
Drives vs. directories
●   In Windows, drives are directories
●   In Linux, you can have several drives all
    under one overall directory, or nested
    one in another in the directory structure.
●   In Linux, you tell the file system where
    you want a drive to appear by where it
    is mounted. See fstab for more on this.
Where did this come from?
●   This started with a Linux effort in August,
    1993
●   In 1996 some BSD folks decided it should
    be expanded to all Unix-like systems
●   This resulted in the Filesystem Hierarchy
    Standard, which can be found at
    http://www.pathname.com/fhs/pub/fhs-
    2.3.html
Standard?
●   Of course, many distros vary from this to
    some degree, some (Gobo) reject it
    entirely, and MacOS tends to substitute
    more “readable” names, like Library in
    place of lib, etc.
●   Red Hat seems to be pretty faithful
    http://www.redhat.com/docs/manuals/linux/
    RHL-9-Manual/ref-guide/s1-filesystem-
    fhs.html
Standard? 2
●   Distros can vary, but so can programs
●   When you install a program, it may not
    follow the FHS in deciding where to
    place its files
●   So this presentation should be
    considered a guide to how things more-
    or-less ought to work, but YMMV
/
●   This is the symbol for the root of the file
    system in Linux
●   Every directory is “under” root,
    ultimately
●   This is not the same as the user “root”,
    which is the user with God-like powers
    over the system
●   The user “root” does have a directory,
    called /root
/bin
●   Contains many of the commands used on
    the command line
●   Examples include cat, chmod,dmesg, kill,
    ls, mkdir more, ps, pwd, sed, su
●   the above commands, and many others,
    must be in /bin to meet the standard.
●   Other commands can be optionally
    included, such as tar. gzip, netstat, and
    ping
/bin 2
●   There are other commands that are not in
    here
●   They are part of the shell (e.g. cd)
●   For most users, this will be bash, the
    Bourne-Again Shell
●   You can tell by looking at the man pages
●   Commands in /bin will have their own man
    page, commands in bash will have info in
    the bash man page
/boot
●   Contains files needed for boot
    –   kernel
    –   Grub menu (good to know if you are dual-
        booting)
    –   Lilo boot sector backups
●   Contains data that is used before the
    kernel starts executing user-mode
    programs
/dev
●   Kinda-sorta an equivalent to a mashup
    of the Device Manager and
    C:WindowsSystem in Windows
●   Contains a file describing every device,
    and these files can send data to each
    device
●   In Linux, everything is a file or a
    directory
●   We mean it. We really mean it.
/dev 2
●   hda1, hda2, etc. are partitions on the
    first physical IDE drive
●   sda1, sda2, etc. are partitions on the
    first physical SATA drive
●   /dev/cdrom is the optical drive
●   /dev/fd0 is the floppy drive, if you have
    one
●   /dev/dsp is the speaker device
Fun with /dev
●   Try this command out:
    cat /etc/lilo.conf > /dev/dsp
●   The sound you will hear is the sound of
    your /etc/lilo.conf file
●   If you don't have /etc/lilo.conf, substitute
    any other file you do have
●   So, /dev/dsp is the speaker, and the
    speaker is the file /dev/dsp.
More /dev fun
●   The most famous device in /dev is the
    ubiquitous /dev/null
●   Anything sent to this device disappears
    into a black hole, and reappears in
    another galaxy, much to the puzzlement
    of the Lizard people of Zorg in the
    CmfR!&v Galaxy.
/etc
●   Perhaps the most important to understand
●   No binaries can be here, per the standard
●   This is just for configuration files
●   Examples include /etc/inittab, /etc/fstab,
    /etc/passwd, /etc/hosts, /etc/x11,and
    /etc/opt
/etc 2
●   These files are generally text files and
    can be edited using any text editor:
    emacs or vi on the command line, or
    whatever graphical equivalent (e.g.
    gedit, kate) your desktop offers
/etc/inittab
●   Describes what takes place at bootup
●   Includes the runlevel of the system, and
    which processes should be run at each
    runlevel
●   Linux has seven runlevels, from 0-6
/etc/fstab
●   Automatically mounts filesystems
    across multiple drives or partitions, or
    even from remote systems
●   This is where you would place an entry
    if you added a hard drive
●   This file tells the system what drive to
    access, and where to mount it in your
    system
/etc/hosts
●   This is the famous hosts file, which
    matches up names with IP addresses
●   This is like level 1 DNS. The system
    looks here first.
●   This can be used to block sites by
    putting their URL in here and mapping it
    to 127.0.0.1. Great way to get rid of
    Double-Click.
/etc/passwd
●   This is the password file, but it contains
    more: user name, user password, user
    ID, group ID, home directory, and shell.
    It can optionally contain the user's “real
    name”
●   Each user is on its own line
●   Each user can select the shell they
    want to use (most use bash these days)
/etc/opt/
●   This is a directory for the configuration files
    for each system application you install.
    Each application gets its own subdirectory
    under /etc/opt/
●   System applications are not just for one
    user, but for anyone logged in to the
    system
●   This is not mandatory, so see the man
    pages or help for your application
/etc/x11
●   Configuration directory for x11, which is the
    display system for graphical interfaces in
    Linux
●   This can vary with different distros, so
    again you need to check
●   /etc/x11/xorg.conf is the configuration file
    that lets you specify the resolutions your
    monitor and graphics card can display, for
    instance
/home
●   This is where the home directories for
    all of the “ordinary” users are located.
●   The exception is root, which has its own
    home directory, /root/
●   Each user gets a directory with their
    user name: e.g. /home/baracko
●   This can contain configuration files for
    applications that are user-specific
User-specific Configurations
●   These files should be in the /home
    directory, and should begin with a “.”
    character (i.e. “dot files”)
●   If more than one, the files should go
    into a directory with a name that begins
    with the “.” character (i.e. “dot
    directory), and then the files should not
    begin with a “.”
/home Partition?
●   Your home directory is where you
    would place all of your documents,
    videos, MP3s, etc.
●   It can get fairly large
●   It is also the stuff you want to back up,
    and you don't want to lose
●   Putting it on its own partition, or even its
    own physical drive, is not a bad idea
Reinstalling
●   If you have a separate /home partition,
    you can reinstall (or do a clean
    upgrade) and still keep not only your
    data, but many of your file
    configurations
●   Examples are Firefox bookmarks,
    Thunderbird or Evolution e-mail settings
    and mail files, etc.
/lib
●   This is the location for shared library
    files that are used by system programs
●   Shared library files are equivalent to
    Windows' “*.dll” files
●   The files here are intended to be
    libraries for programs in /bin and /sbin,
    i.e. needed to boot the system and run
    the commands in the root file system
/lib 2
●   Also in this directory are kernel modules
●   Other library locations for other
    programs include /usr/lib and
    /usr/local/lib
●   Generally these correspond to where
    the binary is installed, i.e. a binary in
    /usr/bin would put a library in /usr/lib,
    and a binary in /usr/local/bin would put
    a library in usr/local/lib
/media, /mnt
●   This is one where there is no general
    agreement
●   Either directory can be a place to mount
    removable media (e.g. CD, USB drive,
    Floppy disk)
●   /mnt is the older way, and is still used for
    temporarily-mounted file systems
●   At one time, these devices were often
    mounted in the root directory, but that is
    less common today
/media, /mnt 2
●   Either directory is allowed by the standard
●   Most current distro versions will mount
    these devices automatically
●   When they are mounted, an entry will go in
    the directory
●   For USB devices, you want to safely
    unmount before removing. Current
    graphical file managers let you do so in the
    directory (right-click on the device).
/mnt vs. /etc/fstab
●   The distinction is temporary vs.
    permanent
●   A file system that will be permanently
    mounted should get an entry in fstab
●   A file system mounted temporarily will
    get an entry in /mnt when you mount it
●   Again, everything in Linux is a file or a
    directory. If you mount something on
    the command line, a file is created in
    /mnt.
/opt
●   Intended as a place for “optional”
    software, i.e. add-on packages that are
    not part of the default installation
●   Intended for use by sysadmins doing
    something locally, not for software
    developers creating packages
●   Treat this as something deprecated, but
    possibly still there.
/proc
●   Have we mentioned that everything in
    Linux is a file or a directory?
●   Any time a process is created in Linux,
    a corresponding file goes in here
●   Most users have no need to go here,
    but you're an adult, do what you want
●   Gosh, what would happen if you
    deleted a file here?
/root
●   Home directory for the root account
●   Normally, you don't want to be root, and
    you don't want to go here
●   Give yourself a user account, and use
    that for day-to-day stuff. It is much safer
    that way.
/sbin
●   Place for System binaries
●   One of three such directories
    –   /sbin
    –   /usr/sbin
    –   /usr/local/sbin
●   All three hold utilities used for system
    administration, and are intended for the
    root user
/sbin 2
●   /sbin should have those utilities
    essential for booting, restoring,
    recovering, and/or repairing the system
●   Programs used after /usr is known to be
    mounted (i.e. when there are no
    problems) go into /usr/sbin
●   Locally installed sysadmin programs go
    in /usr/local/sbin
/tmp
●   Guess what this one is?
●   Yes, temporary files are placed here
●   Assume that anything in this directory
    will be deleted whenever the system is
    booted
●   If you want to have your own temporary
    directory and not lose files at reboot,
    create one in your home directory,
    i.e. /home/username/temp
/usr
●   Lots of stuff in here
●   Back in the mists of prehistory, these
    were the user directories, equivalent to
    what are now /home directories
●   Now /usr is for shareable data
●   Not intended for software packages, in
    general
/usr/bin
●   Contains executable files for many
    Linux commands
●   These are commands that are not part
    of the core Linux operating system
●   They would go in /bin
●   Examples of commands in here: perl,
    python
/usr/include
●   General use include files, including
    header files, for C and C++
    programming languages
/usr/lib
●   Contains libraries for the C and C++
    programming languages
●   Object files, libraries, and internal files
    not intended to be executed directly by
    users or shell scripts
/usr/local
●   For use by System Administrator when
    installing software locally
●   Must not be over-written when system
    software is updated
●   Generally has same subdirectories
    as /usr
/usr/sbin
●   Non-essential standard system
    binaries, i.e. utilities
●   Essential utilities go in /sbin
/usr/share
●   For read-only architecture independent
    data files
●   Intended to be shared across platforms
    (e.g. i386, Alpha, PPC)
●   Must not change
●   If the contents are variable, go to /var
    e.g. a game file in /usr/share/games
    must be static. Game play logs go in
    /var/games.
/usr/share/man
●   Primary location for man pages for the
    system
/usr/src
●   Source code is placed here, for
    reference purposes only
●   This includes the source code for the
    Linux kernel
/var
●   This is for files that are expected to be
    updated and changed
●   This includes:
    –   mail directories
    –   print spool
    –   logs
    –   web sites
/var 2
●   Because these can be written to
    constantly, they can grow over time
●   On a server, you may want to put /var
    on its own partition to limit the growth
●   This can also prevent the /var directory
    from bringing down the server by using
    up all of the drive space.
/var/lock
●   Contains lock files
●   These files prevent two users (or two
    programs) from trying to access the
    same data at the same time
●   You may need to delete a lock file from
    time to time
/var/log
●   Contains the log files generated by
    programs
Fedora Proposal
●   You may have noticed a lot of /bin
    directories in this strcuture
●   So did Fedora developers Harald Hoyer
    and Kay Sievers
●   Their proposal is called /usr merge
What is /usr merge?
●   Move all executables into /usr/bin
●   Move all related libraries into either
    /usr/lib or /usr/lib64, as needed
Problems with /usr merge
●   LSB adheres to FHS
●   Would break most shell scripts that (for
    example) start #!/bin/sh or #!/bin/bash
●   Would other distros go along? Doe
    Fedora care if they do?
Some benefits to /usr merge
●   Matches what Solaris does already
●   Simplifies
●   Easier to run multiple instances of OS
    on different machines in a network. This
    is particularly true with btrfs.

More Related Content

What's hot (20)

PPT
Linux command ppt
kalyanineve
 
PPTX
Unix Operating System
subhsikha
 
PDF
Linux directory structure by jitu mistry
JITU MISTRY
 
PDF
File System Hierarchy
sritolia
 
PPTX
Introduction to linux ppt
Omi Vichare
 
PPTX
Linux process management
Raghu nath
 
PPT
Linux presentation
Nikhil Jain
 
PPT
Basic Unix
Rajesh Kumar
 
PPTX
Linux ppt
lincy21
 
PPT
Linux - Introductions to Linux Operating System
Vibrant Technologies & Computers
 
PPTX
Linux administration
Yogesh Ks
 
PPT
Linux architecture
mcganesh
 
PPTX
Unix ppt
sudhir saurav
 
PPT
Linux file system
Burhan Abbasi
 
PPT
Linux
Gouthaman V
 
PPT
Windows V/S Linux OS - Comparison
Hariharan Ganesan
 
ODP
Apache ppt
poornima sugumaran
 
PPT
Linux
Kevin James
 
PPTX
Open Source Software
Ali Yavari
 
Linux command ppt
kalyanineve
 
Unix Operating System
subhsikha
 
Linux directory structure by jitu mistry
JITU MISTRY
 
File System Hierarchy
sritolia
 
Introduction to linux ppt
Omi Vichare
 
Linux process management
Raghu nath
 
Linux presentation
Nikhil Jain
 
Basic Unix
Rajesh Kumar
 
Linux ppt
lincy21
 
Linux - Introductions to Linux Operating System
Vibrant Technologies & Computers
 
Linux administration
Yogesh Ks
 
Linux architecture
mcganesh
 
Unix ppt
sudhir saurav
 
Linux file system
Burhan Abbasi
 
Windows V/S Linux OS - Comparison
Hariharan Ganesan
 
Apache ppt
poornima sugumaran
 
Linux
Kevin James
 
Open Source Software
Ali Yavari
 

Similar to Linux Directory Structure (20)

PDF
File system discovery
MOHAMED Elshawaf
 
PDF
File system discovery
DevMix
 
PDF
beginner.en.print
aniruddh Tyagi
 
PDF
beginner.en.print
Aniruddh Tyagi
 
PDF
beginner.en.print
aniruddh Tyagi
 
PDF
Module 3 Using Linux Softwares.
Tushar B Kute
 
PPT
Edubooktraining
norhloudspeaker
 
ODP
Lamp1
Nadhi ya
 
ODP
Lamp
Reka
 
ODP
Lamp1
Reka
 
PPT
Unix Administration 4
Information Technology
 
PDF
Linux introduction (eng)
Anatoliy Okhotnikov
 
PPTX
Introduction to Linux
PRIYATHAMDARISI
 
PDF
Linux Internals - Part I
Emertxe Information Technologies Pvt Ltd
 
PPTX
Linux Presentation
Muhammad Qazi
 
PDF
FreeBSD Portscamp, Kuala Lumpur 2016
Muhammad Moinur Rahman
 
PPT
Tutorial 2
tech2click
 
PPTX
Linux basics
suniljosekerala
 
PPTX
Linux basics
suniljosekerala
 
File system discovery
MOHAMED Elshawaf
 
File system discovery
DevMix
 
beginner.en.print
aniruddh Tyagi
 
beginner.en.print
Aniruddh Tyagi
 
beginner.en.print
aniruddh Tyagi
 
Module 3 Using Linux Softwares.
Tushar B Kute
 
Edubooktraining
norhloudspeaker
 
Lamp1
Nadhi ya
 
Lamp
Reka
 
Lamp1
Reka
 
Unix Administration 4
Information Technology
 
Linux introduction (eng)
Anatoliy Okhotnikov
 
Introduction to Linux
PRIYATHAMDARISI
 
Linux Presentation
Muhammad Qazi
 
FreeBSD Portscamp, Kuala Lumpur 2016
Muhammad Moinur Rahman
 
Tutorial 2
tech2click
 
Linux basics
suniljosekerala
 
Linux basics
suniljosekerala
 
Ad

More from Kevin OBrien (20)

PPTX
American icon pmi
Kevin OBrien
 
ODP
Tls 1.3
Kevin OBrien
 
ODP
Forward Secrecy
Kevin OBrien
 
ODP
Diffie_Hellman-Merkle Key Exchange
Kevin OBrien
 
ODP
Password best practices and the last pass hack
Kevin OBrien
 
ODP
SSL certificates
Kevin OBrien
 
ODP
Encryption basics
Kevin OBrien
 
ODP
Passwords
Kevin OBrien
 
PDF
Hardware Discovery Commands
Kevin OBrien
 
PDF
Introduction to linux
Kevin OBrien
 
PDF
Help, my computer is sluggish
Kevin OBrien
 
PDF
The ps Command
Kevin OBrien
 
PDF
Installing Software, Part 3: Command Line
Kevin OBrien
 
PDF
Installing Software, Part 2: Package Managers
Kevin OBrien
 
PDF
Installing Software, Part 1 - Repositories
Kevin OBrien
 
PDF
Installing Linux: Partitioning and File System Considerations
Kevin OBrien
 
PDF
The ifconfig Command
Kevin OBrien
 
PDF
Find and Locate: Two Commands
Kevin OBrien
 
PDF
The Shell Game Part 4: Bash Shortcuts
Kevin OBrien
 
PDF
The Shell Game Part 3: Introduction to Bash
Kevin OBrien
 
American icon pmi
Kevin OBrien
 
Tls 1.3
Kevin OBrien
 
Forward Secrecy
Kevin OBrien
 
Diffie_Hellman-Merkle Key Exchange
Kevin OBrien
 
Password best practices and the last pass hack
Kevin OBrien
 
SSL certificates
Kevin OBrien
 
Encryption basics
Kevin OBrien
 
Passwords
Kevin OBrien
 
Hardware Discovery Commands
Kevin OBrien
 
Introduction to linux
Kevin OBrien
 
Help, my computer is sluggish
Kevin OBrien
 
The ps Command
Kevin OBrien
 
Installing Software, Part 3: Command Line
Kevin OBrien
 
Installing Software, Part 2: Package Managers
Kevin OBrien
 
Installing Software, Part 1 - Repositories
Kevin OBrien
 
Installing Linux: Partitioning and File System Considerations
Kevin OBrien
 
The ifconfig Command
Kevin OBrien
 
Find and Locate: Two Commands
Kevin OBrien
 
The Shell Game Part 4: Bash Shortcuts
Kevin OBrien
 
The Shell Game Part 3: Introduction to Bash
Kevin OBrien
 
Ad

Recently uploaded (20)

PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Digital Circuits, important subject in CS
contactparinay1
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 

Linux Directory Structure

  • 1. Linux Directory Structure Kevin B. O’Brien Washtenaw Linux Users Group http://www.lugwash.org
  • 2. General Notes ● Linux derives from Unix and is designed to be multi-user ● This explains some otherwise puzzling choices ● This may have something to do with Fedora proposing to change this Directory Structure
  • 3. Drives 1 ● Linux derives from Unix ● Different from Windows ● Windows starts with drives, which are explicit – C: – D:
  • 4. Drives 2 ● Linux does not make drives explicit. ● You can have one physical drive, several physical drives, partition the drives into multiple partitions, and normally you won’t be aware of it. ● In a file manager, you won’t see drives, just directories ● But if you look in fstab, you will see things like hda1, hda2, sda1, sda2. These are logical drives (either physical or from partitioning)
  • 5. Root ● In Windows, every drive has its own root – C: is the root of the C drive ● In Linux, there is only one root, no matter how many drives you may have – In Linux, / is the root ● Root is ambiguous in one respect, since it can refer to the top of the file structure, and is also the name of the Administrator- type account in Linux.
  • 6. Root 2 ● For our purposes, we will refer to root as the top of the file structure in this presentation.
  • 7. Comparison Linux Windows /home C: Disk /home/data Partitions D: / root /var E: •/boot •/bin F: •etc.
  • 8. Watch out for... ● Windows uses a backslash for everything ● Linux uses a forward slash for everything ● In Windows, the logical drive (e.g. C:) is an important part of the directory structure ● In Linux, logical drives don't mean much. You can even mount a separate physical drive under a directory that is on another drive.
  • 9. Watch out for 2 ● In Windows, case does not matter. The C:Windows directory is the same as the c:windows directory. ● In Linux, everything is case sensitive. The convention in Linux is to use lower case for most things, but the important thing to remember is that /usr/bin is not the same thing as /USR/BIN.
  • 10. Drives vs. directories ● In Windows, drives are directories ● In Linux, you can have several drives all under one overall directory, or nested one in another in the directory structure. ● In Linux, you tell the file system where you want a drive to appear by where it is mounted. See fstab for more on this.
  • 11. Where did this come from? ● This started with a Linux effort in August, 1993 ● In 1996 some BSD folks decided it should be expanded to all Unix-like systems ● This resulted in the Filesystem Hierarchy Standard, which can be found at http://www.pathname.com/fhs/pub/fhs- 2.3.html
  • 12. Standard? ● Of course, many distros vary from this to some degree, some (Gobo) reject it entirely, and MacOS tends to substitute more “readable” names, like Library in place of lib, etc. ● Red Hat seems to be pretty faithful http://www.redhat.com/docs/manuals/linux/ RHL-9-Manual/ref-guide/s1-filesystem- fhs.html
  • 13. Standard? 2 ● Distros can vary, but so can programs ● When you install a program, it may not follow the FHS in deciding where to place its files ● So this presentation should be considered a guide to how things more- or-less ought to work, but YMMV
  • 14. / ● This is the symbol for the root of the file system in Linux ● Every directory is “under” root, ultimately ● This is not the same as the user “root”, which is the user with God-like powers over the system ● The user “root” does have a directory, called /root
  • 15. /bin ● Contains many of the commands used on the command line ● Examples include cat, chmod,dmesg, kill, ls, mkdir more, ps, pwd, sed, su ● the above commands, and many others, must be in /bin to meet the standard. ● Other commands can be optionally included, such as tar. gzip, netstat, and ping
  • 16. /bin 2 ● There are other commands that are not in here ● They are part of the shell (e.g. cd) ● For most users, this will be bash, the Bourne-Again Shell ● You can tell by looking at the man pages ● Commands in /bin will have their own man page, commands in bash will have info in the bash man page
  • 17. /boot ● Contains files needed for boot – kernel – Grub menu (good to know if you are dual- booting) – Lilo boot sector backups ● Contains data that is used before the kernel starts executing user-mode programs
  • 18. /dev ● Kinda-sorta an equivalent to a mashup of the Device Manager and C:WindowsSystem in Windows ● Contains a file describing every device, and these files can send data to each device ● In Linux, everything is a file or a directory ● We mean it. We really mean it.
  • 19. /dev 2 ● hda1, hda2, etc. are partitions on the first physical IDE drive ● sda1, sda2, etc. are partitions on the first physical SATA drive ● /dev/cdrom is the optical drive ● /dev/fd0 is the floppy drive, if you have one ● /dev/dsp is the speaker device
  • 20. Fun with /dev ● Try this command out: cat /etc/lilo.conf > /dev/dsp ● The sound you will hear is the sound of your /etc/lilo.conf file ● If you don't have /etc/lilo.conf, substitute any other file you do have ● So, /dev/dsp is the speaker, and the speaker is the file /dev/dsp.
  • 21. More /dev fun ● The most famous device in /dev is the ubiquitous /dev/null ● Anything sent to this device disappears into a black hole, and reappears in another galaxy, much to the puzzlement of the Lizard people of Zorg in the CmfR!&v Galaxy.
  • 22. /etc ● Perhaps the most important to understand ● No binaries can be here, per the standard ● This is just for configuration files ● Examples include /etc/inittab, /etc/fstab, /etc/passwd, /etc/hosts, /etc/x11,and /etc/opt
  • 23. /etc 2 ● These files are generally text files and can be edited using any text editor: emacs or vi on the command line, or whatever graphical equivalent (e.g. gedit, kate) your desktop offers
  • 24. /etc/inittab ● Describes what takes place at bootup ● Includes the runlevel of the system, and which processes should be run at each runlevel ● Linux has seven runlevels, from 0-6
  • 25. /etc/fstab ● Automatically mounts filesystems across multiple drives or partitions, or even from remote systems ● This is where you would place an entry if you added a hard drive ● This file tells the system what drive to access, and where to mount it in your system
  • 26. /etc/hosts ● This is the famous hosts file, which matches up names with IP addresses ● This is like level 1 DNS. The system looks here first. ● This can be used to block sites by putting their URL in here and mapping it to 127.0.0.1. Great way to get rid of Double-Click.
  • 27. /etc/passwd ● This is the password file, but it contains more: user name, user password, user ID, group ID, home directory, and shell. It can optionally contain the user's “real name” ● Each user is on its own line ● Each user can select the shell they want to use (most use bash these days)
  • 28. /etc/opt/ ● This is a directory for the configuration files for each system application you install. Each application gets its own subdirectory under /etc/opt/ ● System applications are not just for one user, but for anyone logged in to the system ● This is not mandatory, so see the man pages or help for your application
  • 29. /etc/x11 ● Configuration directory for x11, which is the display system for graphical interfaces in Linux ● This can vary with different distros, so again you need to check ● /etc/x11/xorg.conf is the configuration file that lets you specify the resolutions your monitor and graphics card can display, for instance
  • 30. /home ● This is where the home directories for all of the “ordinary” users are located. ● The exception is root, which has its own home directory, /root/ ● Each user gets a directory with their user name: e.g. /home/baracko ● This can contain configuration files for applications that are user-specific
  • 31. User-specific Configurations ● These files should be in the /home directory, and should begin with a “.” character (i.e. “dot files”) ● If more than one, the files should go into a directory with a name that begins with the “.” character (i.e. “dot directory), and then the files should not begin with a “.”
  • 32. /home Partition? ● Your home directory is where you would place all of your documents, videos, MP3s, etc. ● It can get fairly large ● It is also the stuff you want to back up, and you don't want to lose ● Putting it on its own partition, or even its own physical drive, is not a bad idea
  • 33. Reinstalling ● If you have a separate /home partition, you can reinstall (or do a clean upgrade) and still keep not only your data, but many of your file configurations ● Examples are Firefox bookmarks, Thunderbird or Evolution e-mail settings and mail files, etc.
  • 34. /lib ● This is the location for shared library files that are used by system programs ● Shared library files are equivalent to Windows' “*.dll” files ● The files here are intended to be libraries for programs in /bin and /sbin, i.e. needed to boot the system and run the commands in the root file system
  • 35. /lib 2 ● Also in this directory are kernel modules ● Other library locations for other programs include /usr/lib and /usr/local/lib ● Generally these correspond to where the binary is installed, i.e. a binary in /usr/bin would put a library in /usr/lib, and a binary in /usr/local/bin would put a library in usr/local/lib
  • 36. /media, /mnt ● This is one where there is no general agreement ● Either directory can be a place to mount removable media (e.g. CD, USB drive, Floppy disk) ● /mnt is the older way, and is still used for temporarily-mounted file systems ● At one time, these devices were often mounted in the root directory, but that is less common today
  • 37. /media, /mnt 2 ● Either directory is allowed by the standard ● Most current distro versions will mount these devices automatically ● When they are mounted, an entry will go in the directory ● For USB devices, you want to safely unmount before removing. Current graphical file managers let you do so in the directory (right-click on the device).
  • 38. /mnt vs. /etc/fstab ● The distinction is temporary vs. permanent ● A file system that will be permanently mounted should get an entry in fstab ● A file system mounted temporarily will get an entry in /mnt when you mount it ● Again, everything in Linux is a file or a directory. If you mount something on the command line, a file is created in /mnt.
  • 39. /opt ● Intended as a place for “optional” software, i.e. add-on packages that are not part of the default installation ● Intended for use by sysadmins doing something locally, not for software developers creating packages ● Treat this as something deprecated, but possibly still there.
  • 40. /proc ● Have we mentioned that everything in Linux is a file or a directory? ● Any time a process is created in Linux, a corresponding file goes in here ● Most users have no need to go here, but you're an adult, do what you want ● Gosh, what would happen if you deleted a file here?
  • 41. /root ● Home directory for the root account ● Normally, you don't want to be root, and you don't want to go here ● Give yourself a user account, and use that for day-to-day stuff. It is much safer that way.
  • 42. /sbin ● Place for System binaries ● One of three such directories – /sbin – /usr/sbin – /usr/local/sbin ● All three hold utilities used for system administration, and are intended for the root user
  • 43. /sbin 2 ● /sbin should have those utilities essential for booting, restoring, recovering, and/or repairing the system ● Programs used after /usr is known to be mounted (i.e. when there are no problems) go into /usr/sbin ● Locally installed sysadmin programs go in /usr/local/sbin
  • 44. /tmp ● Guess what this one is? ● Yes, temporary files are placed here ● Assume that anything in this directory will be deleted whenever the system is booted ● If you want to have your own temporary directory and not lose files at reboot, create one in your home directory, i.e. /home/username/temp
  • 45. /usr ● Lots of stuff in here ● Back in the mists of prehistory, these were the user directories, equivalent to what are now /home directories ● Now /usr is for shareable data ● Not intended for software packages, in general
  • 46. /usr/bin ● Contains executable files for many Linux commands ● These are commands that are not part of the core Linux operating system ● They would go in /bin ● Examples of commands in here: perl, python
  • 47. /usr/include ● General use include files, including header files, for C and C++ programming languages
  • 48. /usr/lib ● Contains libraries for the C and C++ programming languages ● Object files, libraries, and internal files not intended to be executed directly by users or shell scripts
  • 49. /usr/local ● For use by System Administrator when installing software locally ● Must not be over-written when system software is updated ● Generally has same subdirectories as /usr
  • 50. /usr/sbin ● Non-essential standard system binaries, i.e. utilities ● Essential utilities go in /sbin
  • 51. /usr/share ● For read-only architecture independent data files ● Intended to be shared across platforms (e.g. i386, Alpha, PPC) ● Must not change ● If the contents are variable, go to /var e.g. a game file in /usr/share/games must be static. Game play logs go in /var/games.
  • 52. /usr/share/man ● Primary location for man pages for the system
  • 53. /usr/src ● Source code is placed here, for reference purposes only ● This includes the source code for the Linux kernel
  • 54. /var ● This is for files that are expected to be updated and changed ● This includes: – mail directories – print spool – logs – web sites
  • 55. /var 2 ● Because these can be written to constantly, they can grow over time ● On a server, you may want to put /var on its own partition to limit the growth ● This can also prevent the /var directory from bringing down the server by using up all of the drive space.
  • 56. /var/lock ● Contains lock files ● These files prevent two users (or two programs) from trying to access the same data at the same time ● You may need to delete a lock file from time to time
  • 57. /var/log ● Contains the log files generated by programs
  • 58. Fedora Proposal ● You may have noticed a lot of /bin directories in this strcuture ● So did Fedora developers Harald Hoyer and Kay Sievers ● Their proposal is called /usr merge
  • 59. What is /usr merge? ● Move all executables into /usr/bin ● Move all related libraries into either /usr/lib or /usr/lib64, as needed
  • 60. Problems with /usr merge ● LSB adheres to FHS ● Would break most shell scripts that (for example) start #!/bin/sh or #!/bin/bash ● Would other distros go along? Doe Fedora care if they do?
  • 61. Some benefits to /usr merge ● Matches what Solaris does already ● Simplifies ● Easier to run multiple instances of OS on different machines in a network. This is particularly true with btrfs.