1

I see the following in ~/.bashrc :

 if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
     debian_chroot=$(cat /etc/debian_chroot)
 fi

which means if the variable is not set, and the file exists and is readable, then set the file's content to the variable.

Am I supposed to write something to that file while preparing to chroot?
If yes, then I'll have to remove that file at the end of chroot job!

any explanation or suggestions will be appreciated.

0

1 Answer 1

3

This variable is just for building the default PS1 shell prompt down below:

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

So it is not essential to create the file, although it can be nice having the prompt identifying where you are.

As you can see -r tests for a file and if the user can read it, and if it exists, debian_chroot gets the content of it, so create /etc/debian_chroot inside the chroot with the wording you want. (inside, do not do it at the true root, as won't be inside the chroot )

So if your chroot is at /mnt, the file you would need to modify is /mnt/etc/debian_chroot (and not /etc/debian_chroot).

8
  • By the way, I also edited you post to reference the correct path of /etc/bash.bashrc Dec 8, 2015 at 14:52
  • yes i want to see in my prompt that i'm in chroot like (chroot_env)user@hostname:~$ , and as i see the "debian_chroot" is always null , i want it to have a value when i'm in chroot :)
    – Yunus
    Dec 8, 2015 at 14:52
  • I completed the answer. Dec 8, 2015 at 14:56
  • (your post implies you are trying to do it at the true root, and that is why it is not behaving as you expect) Dec 8, 2015 at 14:59
  • @RuiFRibeiro I corrected your edit since the OP was probably referring to ~/.bashrc. The default .bashrc files on Debian-based distributions contain the lines quoted in the question, there's no reason to assume the OP meant /etc/bash.bashrc.
    – terdon
    Dec 8, 2015 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .