LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   using chroot (https://www.linuxquestions.org/questions/linux-newbie-8/using-chroot-711974/)

tuananh87vn 03-16-2009 09:54 AM

using chroot
 
excuse me,
I don't know how to use chroot to change root of a file. For example, I see that when I run ls -la in /etc, it shows something like resolve.conf -> /etc/resolveconf/run/resolve.conf

so the orginal file is /etc/resolveconf/run/resolve.conf, right? how can I do like that?

can anybody show me how to do :-??

thanks!

openSauce 03-16-2009 10:32 AM

I don't fully understand what you're asking. Are you asking how to create a symbolic link? If so, use ln -s:

Code:

~$ touch file
~$ ln -s file file-link
~$ ls -l file*
-rw-rw-r-- 1 openSauce openSauce 0 2009-03-16 15:30 file
lrwxrwxrwx 1 openSauce openSauce 4 2009-03-16 15:30 file-link -> file
~$


tuananh87vn 03-16-2009 10:37 AM

oh really, so does chroot have anything to do with it?

openSauce 03-16-2009 10:46 AM

No - chroot changes the root directory used for a command.

So e.g. if you have 2 linux distros installed, and the root filesystem of the inactive one is mounted at /mnt/distro2, you can execute
Code:

chroot /mnt/distro2
and your shell will take / to be /mnt/distro2. Other directories will be inaccessible from this shell, and any commands you enter will execute binaries from the 2nd distro (/bin refers to /mnt/distro2/bin, and so on).

tuananh87vn 03-16-2009 11:08 AM

so the ln -s makes the file name have the white color (in redhat or fedora), while the original file has white colour. is that true?

openSauce 03-16-2009 11:19 AM

Colour has nothing to do with it. ln -s creates a new file which is simply a pointer to the target file - see here and here.

Are you talking about the colours in the output of ls? These are determined by the environment variable $LS_COLORS, which is usually set in some startup or profile file in /etc. echo $LS_COLORS will tell you whether or not this variable is set.

tuananh87vn 03-16-2009 11:39 AM

ah yea, got it. thanks alot :D


All times are GMT -5. The time now is 12:24 AM.