Chroot Change the World

Source: Internet
Author: User

What is Chroot?

chroot, i.e.Change root directory (ChangeRootCatalogue). In theLinuxsystem, the system's default directory structure is `/`, which is the root(Root)the beginning. While in usechrootafter that, the system's directory structure will be the specified location as the `/` location.

Why use Chroot?

in passing chroot after that, the directories and files that the system reads will not be under the old system root but under the new root ( that is, the new location is specified ) the directory structure and file, so it brings the benefits of roughly the following 3 A:

1. Increase the security of the system, limiting the user's power;

in passing chroot after that, the root structure and files of the old system will not be accessed under the new root, thus enhancing the security of the system. This is generally used before login (login) to use chroot, so that users can not access some of the specific files.

2. establish a system directory structure isolated from the original system to facilitate user development;

Use chroot , the system reads the directories and files under the new root, which is a directory structure that is not related to the file under the original system root. In this new environment, it can be used to test the static compilation of software and some independent development that is unrelated to the system.

3.< /span> toggle system root directory location, boot Linux system start-up and first aid system, etc. ;

chroot RAM disk (INITRD) Toggle the root position of the system and execute the real init In addition, we can also use the chroot to switch to a temporary system.

Chroot use 1. Create a root directory after chroot. mkdir /var/chroot 2. Using jail+chroot mode, compile and install jail. From Static/dwn/projects/jail/jail.tar.gz can be downloaded to the latest version of jail, which is made by jail  in Developed by the Chroot project team. The package contains C programs, Perl programs, and bash scripts that help automate the creation of Chroot "jail".   First place the jail.tar.gz in any directory and then execute the command: tar xzf jail.tar.gz && cd jail/ SRC modifies the makefile file, in particular the installation path (the default installation path is/tmp/jail), the architecture (jail support for Linux, FreeBSD, IRIX, and Solaris), and the compilation options. Final execution command: Make && make install3. Create a chroot environment using the jail per program script/tmp/jail/mkjailenv /var/ The Chrootjail package provides several Perl scripts as their core commands, including Mkjailenv, Addjailuser, and &NBSP;ADDJAILSW. such as ADDJAILSW will copy the binary executable and other related files (including library files, auxiliary files and device files) from the real file system to the "prison"  .  4. Add common commands for the chroot environment, such as LS, cat, cp , etc./usr/local/bin/addjailsw /var/chroot  Note: If it is centos 7   Children's shoes Please install this software or the above command will be error strace 5. It's not going to go into the chroot environment, because without bash, you need to copy the local bash to the chroot environment ldd /bin/bash =>  (0x00007ffdbd3e5000) => /lib64/  (0x00007f23337da000) => /lib64/  (0x00007f23335d6000) => /lib64/  (0x00007f2333214000)     /lib64/  (0x00007f2333a0a000) cd /var/chroot/cp /lib64/{,,,} ./lib64/cp /bin/bash ./bin ------------------------ Gorgeous split line----------------------------------  How to use yum 1 in a chroot environment. Create an RPM directory mkdir –p /var/chroot/ Var/lib/rpm 2. Specify the rpm rebuild  directory rpm --rebuilddb --root=/var/chroot 3. Download Centos7  yum Source wget Centos-release-7-2.1511.el7.centos.2.10.x86_64.rpm 4. Installing Centos7 yum source rpm -ivh --root=/var/ chroot --nodepscentos-release-7-2.1511.el7.centos.2.10.x86_64.rpm&nbsp5. Install yumyum --installroot=/var/chroot install -y rpm-build yum 6 inside the chroot environment. Copy native parsing files to chroot environment cp /etc/resolv.conf /var/chroot/etc/ 7. Enter Chroot Environment Chroot /var/tmp/chroot  /bin/bash –l

This article is from the "Attitude decides everything" blog, please make sure to keep this source

Chroot Change the World

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