The difference between fakeroot and sudo

Source: Internet
Author: User

Fakeroot can be used to simulate root permissions in order to establish specific permissions with the file owner's compressed files case (tar, AR,. Deb, etc.). Through Ld_preload's dynamic loader feature, users do not have to actually have root privileges. Fakeroot was originally created to create a Debian package for use. For example, when Debian builds the package, it cannot immediately execute make install in the current environment after compiling it, and will need to do install destdir=$ (PWD)/debian/tmp the generated files into the build directory. $ (PWD)/debian/tmp. Then use the entire contents of that directory to generate the Debian package (in fact the package will contain control and maintainer script, etc.). The file owner in this package must be root, so the package command needs to be executed as root. However, you should avoid using root permissions when making Debian packages. In order to solve this contradiction, Fakeroot was developed. In a fakeroot environment, manipulating files is like working with a file as root. However, the permissions of the files in the system are actually the original permissions. The file owner in this package must be root, so the package command needs to be executed as root.

2The difference between fakeroot and sudo Fakeroot cannot get root permission, sudo can. Fakeroot is only disguised as root, it can not change the need for root permissions to change the file, it just let the program execution in accordance with the root of the situation to run, and the operation of the file is actually under the ordinary user.
12 Fakeroot tar Cvf/tmp/local.tar/usr/localsudo tar cvf/tmp/local.tar/usr/local
The above two commands will be established in/TMP under the Local.tar,tar file name will start with/, but the previous command generated files belonging to the current user, the next command generated files are root.

3 Example Fakeroot records each file right through faked. The following example is performed by Fakeroot Bash, and specific instructions you can notice that the instruction used must have Superuser privileges to execute correctly. These permissions are temporarily emulated and recorded by Fakeroot. After you log out of bash, all files remain in their original permissions. $ whoamijoost$ fakeroot/bin/bash# whoamiroot# Mknod hda3 B 3 # ls-ld hda3brw-r--r--1 root root 3, 1 Jul 2 22:58 hda3# Chown joost:root hda3# ls-ld hda3brw-r--r--1 joost Root 3, 1 Jul 2 22:58 hda3# ls-ld/drwxr-xr-x root root 1024x768 June 21:50/# chown joost:users/# chmod a+w/# ls-ld/drwxr-xr-x root root-1024x768 21:50/# chown joost:users/# Ch MoD a+w/# ls-ld/drwxrwxrwx Joost users 1024x768 June 21:50/# exit$ ls-ld/drwxr-xr-x root root 17 21:50 $ ls-ld hda3-rw-r--r--1 Joost users 0 Jul 2 22:58 hda3

The difference between fakeroot and sudo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.