Check if running chrooted

This script checks if we are running in a chroot environment

# Name:
# Author:
# Function: check if the script is running within a chroot environment
# Parameter: none
# Copyright: 2011 GNU GPL v3
if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ];
  then echo "Don’t run this script within the chroot environment"
  exit 1
This entry was posted in bash, chroot, linux, stat, ubuntu. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *