HB Computer Security | Aide Memoire
  • Introduction
  • Core Technical Skills
    • Core Skills
      • Linux
        • Getting to Know Linux
          • Using the Shell
            • Shells, Terminals, and Virtual Consoles
            • Choose your Shell
            • Shell Commands
              • Non-PATH Commands
              • Command History
                • Command Line Editing
                  • Keystrokes for Navigating Command Lines
                  • Keystrokes for Editing Command Lines
                  • Keystrokes for Cutting and Pasting Text from within Command Lines
                • Command Line Recall
                  • Keystrokes for Command Line Recall
              • Connecting and Expanding Commands
                • Piping Between Commands
                • Sequential Commands
                • Expanding Commands
            • Shell Variables
              • Common Shell Variables
            • Aliases
            • Create your Own Shell Environment
              • Modification Ideas
          • Navigating the Linux File System (LFS)
            • Filesystem Commands
            • Listing Files and Directories
            • File Permissions and Ownership
              • Modifying Permissions with chmod
              • Modifying Default Permissions with umask
              • Change File Ownership with chown
            • Copying, Moving, and Removing Files
            • Finding Files
              • locate
              • find
              • grep
            • Downloading Files
              • axel
              • wget
              • curl
                • User-Agent: Googlebot
          • Working with Text Files
            • Using vim and vi to Edit Text Files
              • Starting with vi
              • Adding Text
              • Moving Around in the Text
            • Text Manipulation
        • System Administration
          • Installing Linux
            • Installing from Live Media
            • Installing in the Enterprise
            • Partitioning Hard Disks
              • Tips for Creating Partitions
          • Account Administration
            • The root Account
              • Becoming root with su
              • sudo
                • The /etc/sudoers File
                • Granting sudo privileges
                  • visudo Guidance
                • Useful sudo Hints
            • Other Administrative Accounts
            • Standard User Accounts
              • Risks of userdel: Orphaned Files
          • Graphical Remote Administration
            • Cockpit
              • Installation Guide
            • Remote Desktop Protocol with xrdp
              • Installation and Configuration
            • Remote Desktop with vnc
              • Installation and Configuration
              • Running VNC as a System Service
          • Managing Running Processes
            • Listing Processes
              • ps
              • top
              • htop
            • Backgrounding and Foregrounding
              • Starting a Background Process
              • Using Foreground and Background Commands
            • Killing and Recining Processes
              • kill and killall
          • Managing Software
            • Managing Software from the Desktop
            • Going Beyond the Limitations of Software Center
              • Debian Packages
                • Advanced Package Tool (apt)
                • Repositories
                • dpkg
        • Shell Scripting
          • Variables
            • Command Substitution
            • Arguments
          • Reading User Input
          • if, else, and elif
          • BOOLEAN Logic
          • Loops
            • for Loops
            • while Loops
          • Functions
          • Local Vs Global Variables
          • Summary
        • Securing Linux
      • Windows
        • Security Hardening
Powered by GitBook
On this page

Was this helpful?

  1. Core Technical Skills
  2. Core Skills
  3. Linux
  4. Getting to Know Linux

Navigating the Linux File System (LFS)

PreviousModification IdeasNextFilesystem Commands

Last updated 1 year ago

Was this helpful?

Imagine Linux's File System (LFS) as the backbone of where all your computer's data is stored. Drawing inspiration from UNIX, one cool thing about Linux is that it treats almost everything – be it data, commands, shortcuts, or whatever – as items in the filesystems. Knowing where things are, and understanding how to get around the filesystem from the shell, are critical skills in Linux!

Now, all this data lives inside what we call directories, or "folders" as you probably know them if you are predominantly a Windows user. And these directories? They can house both files and other nested directories. Think of it as a family tree. To find a file or a directory, you can be all formal and use the full address, like /home/chris/myfile.txt. Or, if you're already in /home/chris, just saying myfile.txt gets the job done.

Picture the Linux file layout as an upside-down tree. At the very top, we've got the daddy of all directories, the root, depicted as a simple slash /. And nope, it's NOT the same as the root user... Dive deeper, and you've got its children: common directories like bin, dev, home, and a few others. Each of these can have their own little set of subdirectories. So, if you ever sketch this out, you'd see a sprawling family tree, or hierarchy, starting with the root directory at the top:

Let's focus on one of the directories found just below the LFS root: the /home directory.

Inside, there's a specific space for my user, named chris. The directory typically shares the same name as the user account. My space is well-organised. I have areas designated for Desktop items, Documents, Downloads, and several other folders.

Now, inside my Documents directory, there's a subdirectory named memos, and within that, a file named memo1.doc:

  • If I want to reference this file from anywhere in the system, I'd say it's located at /home/chris/Documents/memos/memo1.doc - this is known as the absolute path as it is true no matter where within the file system I am currently working

  • However, if I were already navigating within /home/chris/, I could shorten my reference to Documents/memos/memo1.doc - this is known as a relative path because it is only true when considered in relation to my current working directory

There are several directories within Linux that are of interest, and it's worth getting familiar with them:

Directory

Description

/bin

Contains common Linux user commands, such as ls, sort, date, and chmod. /boot Has the bootable Linux kernel, initial RAM disk, and boot loader configuration files (GRUB)

/dev

Contains files representing access points to devices on your systems. These include terminal devices (tty), hard disks (hd or sd), RAM (ram), and CD-ROM(cd*). Users can access these devices directly through these device files; however, applications often hide the actual device names to end users

/etc

Contains administrative configuration files. Most of these files are plain-text files that, given the user has proper permission, can be edited with any text editor

/home

Contains directories assigned to each regular user with a login account. The root user is an exception, using /root as their home directory (see below)

/media

Provides a standard location for automounting devices (removable media in particular). If the medium has a volume name, that name is typically used as the mountpoint. For example, a USB drive with a volume name of myusb would be mounted on /media/myusb

/lib

Contains shared libraries needed by applications in /bin and /sbin to boot the system

/mnt

A common mount point for many devices before it was supplanted by the standard /media directory. Some bootable Linux systems still use this directory to mount hard disk partitions and remote filesystems. Many people still use this directory to temporarily mount local or remote filesystems, which are not mounted permanently.

/misc

A directory sometimes used to automount filesystems upon request

/opt

Directory structure available to store add-on application software

/proc

Contains information about system resources

/root

Represents the root user’s home directory. The home directory for root does not reside beneath /home for security reasons

/sbin

Contains administrative commands and daemon processes

/sys

Contains parameters for such things as tuning block storage and managing cgroups

/tmp

Contains temporary files used by applications

/usr

Contains user documentation, games, graphical files (X11), libraries (lib), and a variety of other commands and files that are not needed during the boot process. The /usr directory is meant for files that don’t change after installation.

In theory, /usr could be mounted read-only

/var

Contains directories of data used by various applications. In particular, this is where you would place files that you share as an FTP server (/var/ftp) or a webserver (/var/www). It also contains all system log files (/var/log) and spool files in/var/spool(such as mail, cups, and news).

The/var directory contains directories and files that are meant to change often. On server computers, it is common to create the /var directory as a separate filesystem, using a filesystem type that can be easily expanded

A visual depiction of the LFS