LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-03-2006, 06:53 AM   #1
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Rep: Reputation: 31
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
 
Old 04-03-2006, 10:36 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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".
 
Old 04-03-2006, 01:22 PM   #3
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
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.
 
Old 04-03-2006, 02:32 PM   #4
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
Here is a link to die.net. Excellent resource!!!!

http://www.die.net/search/search.cgi?words=chroot
 
Old 04-03-2006, 04:08 PM   #5
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
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.
 
Old 04-03-2006, 04:29 PM   #6
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
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

Last edited by whansard; 04-03-2006 at 04:31 PM.
 
Old 04-04-2006, 12:32 AM   #7
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
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
 
Old 04-04-2006, 02:52 AM   #8
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
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
 
Old 04-04-2006, 08:25 PM   #9
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
dsids>
Could you please use your shift key when appropriate, and actually spell out the words you want to use? Thanks.
 
Old 04-05-2006, 12:55 AM   #10
dsids
Member
 
Registered: Mar 2006
Distribution: FC4
Posts: 184

Original Poster
Rep: Reputation: 31
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

Last edited by dsids; 04-05-2006 at 01:44 AM.
 
Old 04-05-2006, 06:07 AM   #11
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
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/
 
Old 04-05-2006, 07:30 PM   #12
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
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.
 
Old 04-05-2006, 08:06 PM   #13
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
Location: Bawstun area

flavor.

i understand though. i have more than enough of my share of things that get on my nerves.
 
Old 09-15-2018, 12:20 PM   #14
ahmermansoor
LQ Newbie
 
Registered: Jul 2018
Distribution: centos 7, rhel 7
Posts: 7

Rep: Reputation: 1
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
 
Old 09-17-2018, 01:46 AM   #15
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 10:30 AM
can't chroot shanenin Linux - Software 1 01-25-2005 04:43 PM
Chroot SSH small howto. ldp Linux - Security 1 01-12-2005 05:50 AM
what is chroot ? sixth_sense Linux - General 4 05-03-2004 07:58 AM
Howto update KDE and howto switch off kdm/gdm Canaris Linux - Software 1 06-15-2003 08:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration