• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

fakeroot Command Examples in Linux

by Deepika

“fakeroot” is a command-line tool in Linux-based systems that allows a user to run a command in an environment that mimics root privileges for file manipulation. This means that a user can execute commands as if they were the root user, without actually having root access.

The main use of fakeroot is to create a package or a package-like environment while running as a normal user, allowing the user to create files with permissions and ownership that would normally require root access. This is useful for creating Debian packages, for example, as the package maintainer does not need to run the process as root.

Fakeroot uses the LD_PRELOAD mechanism to intercept system calls that change the file ownership and permissions, and redirects them to an internal library. This library keeps track of the changes and applies them when the command finishes.

fakeroot Command Examples

1. Start the default shell as fakeroot:

# fakeroot

2. Run a command as fakeroot:

# fakeroot -- command command_arguments

3. Run a command as fakeroot and save the environment to a file on exit:

# fakeroot -s path/to/file -- command command_arguments

4. Load a fakeroot environment and run a command as fakeroot:

# fakeroot -i path/to/file -- command command_arguments

5. Run a command keeping the real ownership of files instead of pretending they are owned by root:

# fakeroot --unknown-is-real -- command command_arguments

6. Display help:

# fakeroot --help

Filed Under: Linux

Some more articles you might also be interested in …

  1. screenkey Command Examples in Linux
  2. nixos-rebuild Command Examples in Linux
  3. terminator Command Examples in Linux
  4. Oracle Software Group Accounts OSDBA, OSOPER, Oracle Inventory group
  5. blastn: command not found
  6. fwupdmgr Command Examples in Linux
  7. pvdisplay Command Examples in Linux
  8. “Abort command issued nexus” error messages in /var/log/messages file
  9. How to convert text files to all upper or lower case
  10. phar Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “az storage blob” Command Examples (Manage blob storage containers and objects in Azure)
  • “az storage account” Command Examples (Manage storage accounts in Azure)
  • “az sshkey” Command Examples (Manage ssh public keys with virtual machines)
  • “az redis” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright