- Updated: January 31, 2026
- 7 min read
Introducing modetc: A Linux Kernel Module for Dynamic Dotfile Path Rewrites
modetc: Linux Kernel Module for Dotfile Path Rewriting – UBOS Tech News
modetc is a lightweight Linux kernel module that transparently rewrites dot‑file paths, letting developers move configuration files to any location while applications continue to see them at their original locations.
What Is modetc and Why Does It Matter?
In modern Linux environments, many legacy applications stubbornly read configuration files from hard‑coded locations such as ~/.ssh or ~/.config. This behavior clashes with the XDG Base Directory Specification, which encourages storing user data under ~/.config, ~/.local, and similar directories. modetc solves the problem at the kernel level by intercepting VFS calls and substituting the requested path with a user‑defined alternative. The result is a “nuclear option” that works for both dynamically and statically linked binaries, without requiring source changes or wrapper scripts.
The module is open‑source, released under GPL‑3.0, and targets developers who need a reliable, low‑overhead method to relocate dotfiles across a variety of distributions. Its design is deliberately simple: a set of plain‑text rewrite rules applied in order, with optional debugging and runtime control via /proc/modetc.
Key Features
- Kernel‑space path rewriting – no user‑space proxies required.
- Supports both absolute and relative paths that start with the home directory.
- Simple rule syntax – one
<match> <replacement>pair per line. - Runtime control: pause, reload, or query the module via
/proc/modetc. - Debug mode for detailed logging of each rewrite operation.
- Maximum of 16 rules, keeping the footprint minimal.
Configuration and Usage Details
modetc is configured through module parameters passed at load time or via /etc/modprobe.d/modetc.conf. The most common parameters are:
| Parameter | Description | Default |
|---|---|---|
homedir |
Base directory that will be rewritten (e.g., /home/alice). |
— |
default_rule |
Fallback replacement applied when no specific rule matches. | — |
rules_file |
Path to the plain‑text file containing rewrite rules. | /etc/modetc.conf |
debug |
Enable verbose logging (0 = off, 1 = on). | 0 |
Example of loading the module with custom parameters:
sudo modprobe modetc homedir=/home/alice default_rule=var/lib/ rules_file=/etc/modetc.conf debug=1
Rules are defined in /etc/modetc.conf using a tab‑separated format. Whitespace matters, and comments start with #. Below is a typical rule set that moves SSH configuration and XDG‑compliant directories:
# Move SSH dotfiles
.ssh var/lib/ssh
# XDG‑compliant rewrites
.config/ etc/
.local/state/ var/lib/
.cache/ var/cache/
To pause rewriting without unloading the module, write to the control file:
echo pause | sudo tee /proc/modetc
Reading the current status is as simple as:
cat /proc/modetc
Building and Installing modetc
The source tree ships with a Makefile and optional Nix expressions for reproducible builds. For most developers, the classic make workflow is sufficient:
- Clone the repository:
git clone https://github.com/rnhmjoj/modetc.git - Enter the directory:
cd modetc - Compile the module:
make - Install the kernel object:
sudo make install - Refresh module dependencies:
sudo depmod -a - Load the module with your preferred parameters (see above).
If you are on NixOS, the process is even smoother:
nix-build -A module
sudo insmod result/lib/modules/*/misc/modetc.ko
Testing in a virtual machine before deploying to production is strongly recommended. The repository includes a test target that runs a suite of path‑rewriting checks.
How Does modetc Compare to Other Solutions?
Several projects attempt to solve the same problem, but each takes a different approach:
| Solution | Method | Pros | Cons |
|---|---|---|---|
| libetc | LD_PRELOAD wrapper around libc calls. | Works for dynamically linked binaries; easy to toggle. | Fails for statically linked programs; requires user‑space library. |
| rewritefs | FUSE filesystem that rewrites paths on the fly. | Transparent to all programs; no kernel changes. | Significant I/O overhead; extra mount management. |
| modetc | Kernel‑space kprobe injection into VFS calls. | Zero‑copy, minimal latency; works for static binaries. | Limited to 16 rules; no regex support. |
In short, if you need a lightweight, low‑latency solution that works across the entire Linux ecosystem, modetc is the most pragmatic choice.
Licensing and Community
modetc is released under the GNU General Public License v3.0. This ensures that anyone can use, modify, and redistribute the code, provided that derivative works also remain open source. The project is maintained by a small core team, with contributions welcomed via GitHub pull requests.
The open‑source nature aligns well with the broader UBOS open‑source ecosystem, where developers can combine kernel‑level tools like modetc with higher‑level AI services to build end‑to‑end solutions.
Real‑World Use Cases on the UBOS Platform
Imagine a SaaS product that stores user‑specific configuration in a secure, isolated directory (/var/lib/app‑config) but must support legacy CLI tools that still look for ~/.config. By loading modetc inside a container orchestrated by the UBOS platform overview, you can rewrite those paths on the fly, keeping the container immutable while satisfying the tool’s expectations.
For UBOS for startups, this means faster time‑to‑market: developers no longer need to fork or patch third‑party binaries. The same principle applies to UBOS solutions for SMBs, where legacy on‑prem software often refuses to adopt modern directory layouts.
Moreover, the Enterprise AI platform by UBOS can pair modetc with AI‑driven configuration generators. For example, an OpenAI ChatGPT integration could suggest optimal rewrite rules based on a user’s existing dotfile structure, while the Chroma DB integration stores those rule sets for quick retrieval across multiple deployments.
AI‑Enhanced Automation
The AI marketing agents can automatically generate documentation for each rewrite rule, ensuring compliance teams understand why a particular path was moved. Similarly, the ChatGPT and Telegram integration can notify administrators in real time when a rule is added, modified, or paused.
For voice‑first workflows, the ElevenLabs AI voice integration can read out the current rule set, making audits accessible even on the go.
Accelerating Development with UBOS Templates
UBOS offers a rich template marketplace that includes ready‑made modules for common tasks. While there isn’t a dedicated “modetc template” yet, developers can start from the AI Article Copywriter template to generate documentation, or use the AI SEO Analyzer to ensure the rewrite rules don’t unintentionally affect SEO‑critical files.
The Web app editor on UBOS lets you edit /etc/modetc.conf directly from a browser, while the Workflow automation studio can trigger a reload of the module whenever the configuration file changes in a Git repository.
Pricing, Support, and Community Resources
While modetc itself is free, organizations that want professional support can leverage the UBOS pricing plans. The plans include priority issue triage, custom rule‑generation services, and dedicated onboarding sessions.
The UBOS partner program also welcomes system integrators who wish to bundle modetc with other UBOS AI services for enterprise customers.
For inspiration, browse the UBOS portfolio examples where several clients have already deployed kernel‑level path rewriting to modernize legacy workloads.
Get Started with modetc Today
If you’re a developer or sysadmin looking to clean up dotfile chaos, modetc offers a battle‑tested, open‑source solution that integrates seamlessly with the UBOS homepage ecosystem. Follow these steps to begin:
- Clone the repository and build the module (see the Building section).
- Create a
/etc/modetc.conffile with your rewrite rules. - Load the module with
modprobeand verify withcat /proc/modetc. - Integrate with UBOS AI services for automated rule generation and monitoring.
- Join the community on GitHub and share your use‑cases.
For a deeper dive into the original announcement and technical details, see the original news article.
Ready to modernize your Linux environment? Explore the About UBOS page to learn how our platform can accelerate your journey.
Andrii Bidochko
CTO UBOS
Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.