DEV Community

Cover image for Linux Essentials: Managing Files and Folders in a Simulated Company Setup
Oluwanifesimi
Oluwanifesimi

Posted on

Linux Essentials: Managing Files and Folders in a Simulated Company Setup

Introduction
Linux is a powerful operating system used in everything from servers and cloud platforms to smart devices and supercomputers. One of the first things to learn when working with Linux is how to manage files and folders. This skill is essential for anyone interested in system administration, DevOps, or automation.

In this project, “File & Directory Management for a Mock Company using Linux”, you’ll set up and organize a sample company’s folder structure. It’s a hands-on way to learn how to move through the Linux filesystem, work with files, and use key commands like mkdir, cd, ls, and more. You’ll also practice using both absolute and relative paths to navigate and manage data.

What You’ll Do
Here are the practical tasks you’ll complete step by step:

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

company

1.2 Create department subdirectories:

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

company/hr/marketing
1.3 Verify the directory structure:

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

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.
cd/ls

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.

sample files

  • You can confirm they were created with: ls ~/company/hr ls ~/company/finance ls ~/company/dev ls ~/company/marketing confirm

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
transfer

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. send

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

  • 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
backup

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 extract

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 ubuntu
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

part1
part2

Step 6: Check Storage & File Sizes

Commands:
6.1 Check company folder size:
du -sh ~/company

size
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.
mounted

Conclusion
This project showed how Linux can be used to build and manage a realistic company file system. By setting up department folders, organizing files, renaming and moving them, and securing everything with backups and compression, you’ve practiced essential skills that are key for system administrators and DevOps professionals.

Throughout the exercises, you learned how to:

  • Create and move through directories using mkdir and cd
  • Work with files using touch, ls, cp, and mv
  • Search for files and content using find and grep
  • Back up and restore data with tar and gzip
  • Check storage usage using du and df

Applying these commands in a mock company setup helped you see how Linux is used in real-world tasks like organizing data, managing backups, and keeping systems efficient. These foundational skills prepare you for more advanced topics like scripting, user permissions, automation, and cloud deployment. You’re now one step closer to becoming confident in Linux system administration.

Top comments (0)