temporary

문서의 이전 판입니다!


chroot 상태 확인

from https://unix.stackexchange.com/questions/14345/how-do-i-tell-im-running-in-a-chroot

## stat - Display file or file system status.

## -c  --format=FORMAT   use the specified FORMAT instead of the default;
##                          output a newline after each use of FORMAT

## The valid format sequences for files (without --file-system):
##  %d   device number in decimal (st_dev)
##  %i   inode number

## 현재 root의 device, inode가 /sbin/init가 실행한 root와 동일한지 확인
## PS1에 적용하면 normal과 chroot간에 다른 PS1 사용 가능

if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then
  echo "We are chrooted!"
else
  echo "Business as usual"
fi

  • temporary.1713083449.txt.gz
  • 마지막으로 수정됨: 2024/04/14 08:30
  • 저자 baecy