fakeroot

simulated root environment for package building

TLDR

Start default shell as fakeroot
$ fakeroot
Run a command as fakeroot
$ fakeroot -- [command] [command_arguments]
Run command and save environment on exit
$ fakeroot -s [path/to/file] -- [command] [command_arguments]
Load environment and run command
$ fakeroot -i [path/to/file] -- [command] [command_arguments]
Keep real ownership instead of pretending root
$ fakeroot [-u|--unknown-is-real] -- [command] [command_arguments]
Display help
$ fakeroot [-h|--help]

SYNOPSIS

fakeroot [options] [command]

DESCRIPTION

fakeroot runs commands in an environment that fakes root privileges for file manipulation. It intercepts system calls to make files appear owned by root without actual root access.The tool uses LD_PRELOAD to intercept library calls and maintain a database of fake ownership and permission information. When a program creates a file, fakeroot records it as owned by root (uid 0, gid 0) while the actual file on disk retains the user's ownership.This is commonly used for building packages (particularly Debian .deb packages) that need to create root-owned files. The saved environment (-s/-i) allows preserving fake ownership across multiple commands and sessions.

PARAMETERS

-s file

Save fakeroot environment on exit.
-i file
Load fakeroot environment from a previous session.
-u, --unknown-is-real
Keep real ownership of files not tracked by fakeroot.
-b fd
File descriptor for faked library to use.
-h, --help
Display help.
-v, --version
Display version.

INSTALL

sudo dnf install fakeroot
sudo pacman -S fakeroot
sudo apk add fakeroot
sudo zypper install fakeroot
brew install fakeroot
nix profile install nixpkgs#fakeroot

CAVEATS

Does not provide real root privileges. Only fakes ownership information. Used extensively in package building systems like dpkg-buildpackage.

SEE ALSO

sudo(8), dpkg-buildpackage(1)