Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the debian_chroot variable in my bashrc file? and what is it doing here?

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

share|improve this question
    
not much about it in the way of google, but you might like to look at ubuntuforums.org/showthread.php?t=55243 –  Stefan Oct 15 '10 at 21:39
    
It's ugly and unfriendly code that you will rarely ever use in your otherwise simple and elegant PS1 prompt. It seems that there would be a better way to do this (perhaps an if $debian_chroot; then ... else block). –  Stefan Lasiewski Oct 16 '10 at 3:09
    
The PS1 I posted is default (K)Ubuntu prompt –  Falmarri Oct 16 '10 at 8:42
    

1 Answer 1

Chroot is a unix feature that lets you restrict a process to a subtree of the filesystem. One traditional use is FTP servers that chroot to a subset of the filesystem containing only a few utilities and configuration files, plus the files to serve; that way, even if an intruder manages to exploit a bug in the server, they won't be able to access files outside the chroot. Another common use is when you're installing or repairing a unix system and you boot from a different system (such as a live CD): once a basic system is available, you can chroot into it and do more work.

The prompt setting includes the content of $debian_chroot in the prompt, inside parentheses, unless it is empty. This variable is initialized in /etc/bash.bashrc to the contents of the file /etc/debian_chroot. Thus, if you follow the convention to include a name for your chroots at the location /path/to/chroot/etc/debian_chroot, your prompt will contain an indication of which chroot you're in. A program that follows this convention is schroot, a tool for building and using chroots conveniently (I think the original intent was to facilitate having a stable Debian in a chroot inside an unstable or testing Debian, but the program has evolved quite a bit beyond that).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.