Os Chroot
# Python2.x 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 a specified directory. Using this function requires administrator privileges.
### Syntax
The syntax for the **chroot()** method is as follows:
os.chroot(path);
### Parameters
* **path** -- The directory to 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 # Set the root directory to /tmp os.chroot("/tmp")print "Root directory changed successfully!!"
The output of executing the above program is:
Root directory changed successfully!!
[ Python OS File/Directory Methods](#)
YouTip