Something Like .profile or .bashrc Inside chroot

carlarogers

Member
Joined
Jan 1, 2020
Messages
58
Reaction score
10
Credits
527
I have been running Linux, mostly Debian, as part of my job for a few years, but I am not formally trained in the system.

I have setup chrooted directories a few different ways. They seem to be functioning the way they are supposed to.

Unfortunately, there is a basic requirement I am stumped on. In my narrow minded way, I am thinking there must be a way to initialize aliases, paths, command prompt format, etc. when switching into a chrooted mode. I have made exactly no progress toward breathing any kind of life into this aspect of the chroot. This limitation prohibits me opening a new development server to a group of developers waiting for me to finish configuring the system for them.

I have searched with GoogleBingDuckGo and not found the clues I need.

If you can help me get going in the right direction on this, I would be extremely grateful.

Thank you.
 
Last edited:


It looks like it will help. I will have to work with it later. Thank you for providing a lead on this. It seems like such a basic requirement, I am surprised a solid solution to this is not well known. Operating without any configuration for getting you started seems incredibly lame to me. What do people do, put files in the chroot directory that have to be run manually to setup the environment? I am setting this up for relatively inexperienced people. i was expecting to have the environment set itself up when they login.

I feel like I must be missing something everyone knows except me.

******************************************
Reread the question at stack and noticed "the new shell will read from /root/.profile on load."

That is the part I did not recognize. With that, I think I can get muy thing going. However, it still seems odd to me that the root users .profile would drive the config of a chroot directory that is intended for use by users without root privileges. It is like using a the Queen as if it is a pawn.
 
Last edited:
Am I reading this right? When starting a chroot, the root user's .profile is used to initalize the environment? Or it CAN be read?
 
I had the very same problem, and found out the solution:
It seems that, if you chroot with non-root user, chroot's bash still only looks for .bash_profile, .bashrc and/or .profile, whithin a "/root" directory inside the chrooted directory.
Put those files there, and it'll work.
 

Members online


Top