os.chroot(path)
path -- 這是要為當前進程設定為根路徑的路徑。
#!/usr/bin/python3 import os, sys # To set the current root path to /tmp/user os.chroot("/tmp/usr") print ("Changed root path successfully!!")
Changed root path successfully!!