DEV Community

Cover image for Mastering Linux: File & Directory Management with a Mock Company Project
SUBAIR NURUDEEN ADEWALE
SUBAIR NURUDEEN ADEWALE

Posted on

Mastering Linux: File & Directory Management with a Mock Company Project

Introduction

Linux is one of the most powerful and widely used operating systems in the world. From running servers and cloud platforms to powering embedded systems and supercomputers, its flexibility makes it a must-learn skill for anyone in technology. At the heart of Linux usage is the ability to effectively manage files and directories. Mastering this fundamental skill not only boosts efficiency but also lays the groundwork for advanced system administration, DevOps, and automation.

In this project, “File & Directory Management for a Mock Company using Linux”, we simulate a real-world environment by creating and managing a company’s directory structure. This hands-on exercise helps learners understand how to navigate the Linux filesystem, manipulate files, and organize data effectively, using both absolute and relative paths, along with essential commands.

Tasks to Cover in the Project

Here are the step-by-step applied tasks you will complete:

Set Up the Company Structure

  • Create directories for different departments (HR, Finance, Dev, Marketing).

Create and Manage Files

  • Add employee records, policy documents, budgets, and project files.
  • Use commands like touch, ls, cat.

Copy, Move, and Rename Files

  • Share policies across departments.
  • Move misplaced project files.
  • Rename files correctly.

Search and Find Files

  • Use find to locate files.
  • Search content inside files with grep.

Compress and Backup Data

  • Archive the company directory with tar and gzip.
  • Extract the archive to test backup recovery.

Check Storage Usage

  • Monitor directory size with du.
  • Check disk space with df.

Work with Paths

  • Practice using absolute paths (/home/user/company/...).
  • Practice using relative paths (../finance/budget.txt).

Step 1 Create the Company Folder Structure

We will first create a parent directory named company, and inside this directory, we will create four subdirectories representing different departments of the organization:

Commands Used and Their Meanings

  • mkdir -p ~/company
  • mkdir: Make Directory (creates a new folder)
  • -p: Parents flag (creates parent directories if they don't exist)
  • ~/company: Path to the new directory (in the user's home folder)
  • Meaning: Create a directory called "company" in the home directory
  • mkdir -p ~/company/hr (and similar commands)
  • Meaning: Create subdirectories (hr, finance, marketing, dev) inside the company directory
  • ls
  • Meaning: List contents of the current directory
  • cd company
  • cd: Change Directory
  • Meaning: Move into the company directory

1.1 Create the main company directory:

- mkdir -p ~/company

1.2 Create department subdirectories:

mkdir -p ~/company/hr
mkdir -p ~/company/finance
mkdir -p ~/company/marketing
mkdir -p ~/company/dev

1.3 Verify the directory structure:

ls
This shows all files and directories in your current location, including the new "company" directory.

1.4 Navigate into the company directory:
Navigate into the parent directory (company) using the cd command.
*cd * company

ls
This confirms that all four department directories (dev, finance, hr, marketing) were created successfully.

Step 2: Create Some Sample Files

touch → creates empty files.

  • Here we simulate real company documents: HR gets employee records and policies, Finance gets budgets, Dev has project files, and Marketing has strategies.

  • You can confirm they were created with:

ls ~/company/hr
ls ~/company/finance
ls ~/company/dev
ls ~/company/marketing

Step 3: Copy & Rename Files

Copy HR policies to Marketing:

cp copy files from one directory to another directory
ls comfirm the policies.txt file is copied to marketing directory

cp ~/company/hr/policies.txt ~/company/marketing/

mv → use for renaming files.

  • The file in the dev folder (projectA.txt) is spelt wrongly, rename the file to project2025.txt
  • cd into the dev directory
  • ls to list the files in the directory
  • use mv to rename the directory from projectA.txt to project2025.txt
  • use ls to verify your change.

Step 4: Search for Files

  • find → locates files and directories matching a pattern.
  • grep -r → searches inside files for specific words recursively.
  • This is useful for quickly tracking down documents.
  • find ~/company -name "*.txt" locates files and directories that has the .txt files.
  • find ~/company -name "*.txt" locates files and directories that has the .png files.

  • Search for the word “policy” inside files:

grep -r "policies" ~/company

Step 5: Organize with Compression

At some point, every company needs to back up its files to protect against accidental deletion, corruption, or system failure. In Linux, one of the most common tools for this is tar (short for tape archive). It allows you to bundle multiple files and directories into a single archive, and with the right options, compress it to save space.

5.1 Compress the company folder

Command:

tar -czvf company_backup.tar.gz ~/company

  • tar → archives multiple files and directories into one.
  • -c → create a new archive.
  • -z → compress the archive using gzip (makes it smaller in size).
  • -v → verbose mode, shows the progress in the terminal as files are being archived.
  • -f → specifies the filename of the archive (company_backup.tar.gz).
  • ~/company → the folder you want to back up.
  • This command creates a compressed backup file named:
  • company_backup.tar.gz
  • in your current working directory. Extract the backup to test

Command:

tar -xzvf company_backup.tar.gz -C ~/

  • -x → extract files from an archive.
  • -z → tells tar the archive is compressed with gzip.
  • -v → verbose mode, shows files being extracted.
  • -f → specifies the filename of the archive.
  • -C ~/ → tells tar where to extract the files (in this case, your home directory).

This simulates restoring the backup. After extraction, you should see the company folder again in your home directory.

5.2 Compress the company folder:

tar -czvf company_backup.tar.gz ~/company

5.3 Extract it to test:

tar -xzvf company_backup.tar.gz -C ~/

5.4 View whats inside the compressed folder

  • Check what’s inside your archive before extracting:
  • This lists all files and directories stored in the archive.

tar -tzvf company_backup.tar.gz

5.5 Extract into a new folder
Create a new folder (Restorefiles) in the company directory which is the parent directory.

5.5.1 Preparation Setup

mkdir -p ~/company/Restorefiles
cd company
ls
cd ..

  • Created a safe restoration area (Restorefiles) to extract backup files
  • Verified your existing company structure before restoration
  • Positioned yourself in the home directory ready for extraction

5.1.2: Backup Extraction

tar xzvf company_backup.tar.gz -C ~/company/Restorefiles

  • Extracted a compressed backup archive (company_backup.tar.gz)
  • Used safe extraction to an isolated location instead of overwriting original files
  • Preserved the complete directory structure and file permissions

5.1.3 Verification & Inspection

cd ~/company/Restorefiles
ls
cd home
ls
cd vboxuser
ls
cd company
ls

  • Navigated through the extracted backup structure to verify contents
  • Confirmed all data was intact: departments, files, and hierarchy
  • Checked that the backup matched your expected company structure
  • What Your Backup Contained

Step 6: Check Storage & File Sizes

Commands:

6.1 Check company folder size:

du -sh ~/company

the size is 60kilobytes.

6.2 Check overall disk usage

df -h

du -sh → displays size of a directory in human-readable format.

df -h → shows free/used space on mounted filesystems.

Conclusion

This project has demonstrated how Linux can be used to simulate and manage a real-world company’s file system. By creating a structured directory for departments, adding and organizing files, moving and renaming them, and finally securing everything with compression and backups, you have gained practical skills that every system administrator and DevOps engineer must master.

Through these hands-on exercises, you learned how to:

  • Create and navigate directories with mkdir and cd.
  • Manage files using commands like touch, ls, cp, and mv.
  • Search for files and content with find and grep.
  • Back up and restore data with tar and gzip.
  • Monitor storage usage with du and df.

By applying these skills to a mock company environment, you not only practiced Linux commands but also understood their importance in real workplace scenarios such as organizing data, maintaining backups, and ensuring efficient file management. Mastering these fundamentals provides a solid foundation for more advanced topics like shell scripting, permissions, user management, automation, and cloud deployment. With these skills in hand, you are well on your way to becoming confident in Linux system administration.

Top comments (0)