Python method chroot() changes the root directory of the current process to the given path. To use this method, you would need a superuser privilege.
Following is the syntax for chroot() method:
This method does not return any value.
The following example shows the usage of chroot() method.
#!/usr/bin/python import os, sys # To set the current root path to /tmp/user os.chroot("/tmp/usr") print "Changed root path successfully!!"
When we run the above program, it produces the following result:
Changed root path successfully!!
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.