os.chroot Overview
Python os.chroot() method is used to change the root directory of the current process to the specified directory and requires administrator privileges to use this function.
os.chroot Syntax
The chroot() method syntax format is as follows:
os.chroot(path);
os.chroot Parameter
- path – the directory to be set as the root directory.
os.chroot Return value
This method has no return value.
os.chroot Demo
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 "Modification of root directory successful!!!"
The output of executing the above program is:
Modification of root directory successful!!!