LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   howto use chroot (https://www.linuxquestions.org/questions/linux-newbie-8/howto-use-chroot-431293/)

dsids 04-03-2006 06:53 AM

howto use chroot
 
hi there,
can someone plz point me to certain sites where in I can learn howto use chroot.. tried googling a lot but couldnt find any

thanks.
danish

unSpawn 04-03-2006 10:36 AM

tried googling a lot but couldnt find any
LQ has site search. We've got a lot of topics going on. Try it next time. You won't be disappointed, even if your search-fu is at an alltime low.


Check out the LQ FAQ: Security references: post #4: "Chroot, chrooting, jailing, comparimization".

KimVette 04-03-2006 01:22 PM

You searched Google and couldn't find anything? First hit for chroot howto:

http://www.tjw.org/chroot-login-HOWTO/

Also, search for "jailkit" - first hit:

http://olivier.sessink.nl/jailkit/

Both should point you in the right direction, I hope this was helpful (it doesn't make any sense to reinvent the wheel by copy&pasting the howtos here). Let us know if you run into trouble configuring them. :)

DotHQ 04-03-2006 02:32 PM

Here is a link to die.net. Excellent resource!!!!

http://www.die.net/search/search.cgi?words=chroot

saikee 04-03-2006 04:08 PM

Here is my own version based on usage.

Chroot is a mean of jumping from a Linux A into another Linux B.

The steps involved are just booting up Linux A either an installed Linux in the hard disk or from a Live CD, make a temporary partition in /mnt, mount the partition of Linux B and do a chroot.

The result afterward is you will be using the kernel of Linux A but have the access of the Bash shell of Linux B. This facility allows you to repair Linux B especially if it is unbootable. If LInux B is in partition hda7 the commands after booting Linux A to chroot to Linux B are
Code:

mkdir /mnt/hda7
mount /dev/hda7 /mnt/hda7
chroot /mnt/hda7

After the above you will be inside hda7 or Linux B to do whatever you want. To get back to Linux A you need to type
Code:

exit
If the Linux A kernel is compatible with Linux B you can use the GUI too but in general Bash shell or terminal mode is one that is always supported.

Since you need root privilege to chroot so on gaining access into the Linux B you will remain as root and so it can be a form of hacking because you break into an installed Linux without knowing any of its passwords.

whansard 04-03-2006 04:29 PM

i have a bunch of scripts on my system similar to this. say gentoo is installed on hda6. generally you can start another instance of X after chrooting with startx -- :1
you can be running several versions of linux at once along with their graphical environments, switching between themw ith ctl-alt-F7 . . F8 . . . F9

some of the info is from a multiple distributions for development howto on the web.

http://www.faqs.org/docs/Linux-mini/...istro-Dev.html

umount /hda1
umount /hda2
mount /dev/hda6 /mnt/gentoo
mount --bind /proc /mnt/gentoo/proc
# mount --bind /tmp /mnt/redhat/tmp
# chroot /mnt/gentoo /bin/bash --login startx
chroot /mnt/gentoo /bin/bash
umount /mnt/gentoo/tmp
umount /mnt/gentoo/proc
umount /mnt/gentoo
mount /dev/hda1 /hda1
mount /dev/hda2 /hda2

dsids 04-04-2006 12:32 AM

thank you all for your help...i tried out all the pages that you all had provided but im sorry i couldnt understand much....though i did try out the man pages and from a bit of reading i did...

#ldd /bin/ls

after getting all the shared libraries i cp'd them to a directory (/home/dipshi) in the same structure that i got...for eg.../home/dipshi/lib/(shared libraries)..i then even copied ls and bash into the directories

inthe same i did #ldd /bin/bash and cp'd all the libraries in the appropriate structure...and then i did

#chroot /home/dipshi/
bash-3.00#

the ls was working fine...

right now im trying to chroot the /var/tomcat-jakarta and /usr

ill be neeing your help with that..ill get back whenever i get a problem

thank you very much
Danish

dsids 04-04-2006 02:52 AM

hello everyone...as i had told u i would be working on /var/jakarta...
well i did chroot it and made bin, etc, usr/sbin, lib under /var/jakarta-tomcat and copied all the libraries into it......although i could go into jakarta after chroot ing it...i also wanted to create a user under jakarta so that the user could only work under the webapplication direc under jakarta...so i also copied /usr/sbin/useradd to jakarta in the appropriate dir format..after chrooting i tried useradd username, it didnt give any errors so i assumed that a user was created..similarly i copied userdel but when i tried to run userdel..it gave me an error that there was no such user....
the following dir were made by me

#mkdir -p /var/jakarta/bin
#mkdir -p /var/jakarta/lib
#mkdir -p /var/jakarta/etc

#cd /var/jakarta
#touch passwd
#touch group


on opening /var/jakarta/etc/passwd..it showed me entries that a user was created with all the normal entries including a home dir...but when i personally created a home dir under jakarta, no home dirwas created for the user

thanks
danish

KimVette 04-04-2006 08:25 PM

dsids>
Could you please use your shift key when appropriate, and actually spell out the words you want to use? Thanks.

dsids 04-05-2006 12:55 AM

thank you KimVette..I'll work on your advice....

I tried out jailkit and worked on the example that was given in the documentation available on the jailkit website..every command mentioned in the documentation jailkit worked fine but I couldnt figure out how would I come to know whether the user is inside the jail.....

for eg, if I do #chroot /home/username...then by doing

bash#pwd I get / as the new root directory instead of /home/username

but my problem is that I cant figure out how to do the same thing using jailkit....

any help will be greatly appreciated

thanks
danish

whansard 04-05-2006 06:07 AM

i actually enjoy short bursts of leet speech. reading your posts, i didn't even notice the u and plz myself. i think it gives more flavor to things.

on the main question, perhaps you can do a minimal install of linux on a different drive or partition, then get the chroot working, and start deleting stuff out of the environment. perhaps one of those minimal 1 2 or 3 floppy distributions or something like peanut.
http://www.linuxlinks.com/Distributions/

KimVette 04-05-2006 07:30 PM

Quote:

Originally Posted by dsids
thank you KimVette..I'll work on your advice....

I tried out jailkit and worked on the example that was given in the documentation available on the jailkit website..every command mentioned in the documentation jailkit worked fine but I couldnt figure out how would I come to know whether the user is inside the jail.....

Oh that's easy. If you log in as root and ls -l / you will see the contents of the system's root directory - then if you log in as the chrooted user, you will see that user's home directory contents when you ls -l /


Quote:

whansard i actually enjoy short bursts of leet speech. reading your posts, i didn't even notice the u and plz myself. i think it gives more flavor to things.
Personally I find it hard to follow when trying to concentrate on what the person is actually trying to ask, because it's so darn annoying I'm spending more time thinking about how damn lazy people are than I spend thinking about the user's issue. It's lame because so many people think using shorthand which might be appropriate in an SMS message makes them look cool on a technical board.

whansard 04-05-2006 08:06 PM

Location: Bawstun area

flavor.

i understand though. i have more than enough of my share of things that get on my nerves.

ahmermansoor 09-15-2018 12:20 PM

chroot example links
 
Here are two links for RHEL 7 users.

Chroot Jail the Apache Web Server in RHEL/CentOS 7

Chrooted Collaborative Directory for SFTP users in Linux

JJJCR 09-17-2018 01:46 AM

chroot - Wikipedia
https://en.wikipedia.org/wiki/Chroot
Jump to Linux host kernel virtual file systems and configuration files - A chroot on Unix operating systems is an operation that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally cannot access) files outside the designated directory tree.

What does chrooted mean? - LinuxQuestions
https://www.linuxquestions.org/quest...d-mean-355296/

You can also search the idea for Sandboxing :)


All times are GMT -5. The time now is 12:01 PM.