Python os.chroot() Method
Python OS File/Directory Methods
Overview
The os.chroot() method is used to change the root directory of the current process to the specified directory. Using this function requires administrator privileges.
Syntax
chroot()The method syntax is as follows:
os.chroot(path);
Parameters
path-- The directory to be set as the root directory.
Return Value
This method does not return a value.
Example
The following example demonstrates the use of the chroot() method:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os, sys
# 设置根目录为 /tmp
os.chroot("/tmp")
print "修改根目录成功!!"
The output of the above program is:
Successfully modified root directory!!Other Extensions