LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-20-2010, 01:44 PM   #1
x24804
LQ Newbie
 
Registered: Jun 2007
Posts: 12

Rep: Reputation: 0
Is It Possible To Use The cd Command in chroot?


In a script that I'm still writing, I'm trying to build a package from source within a chroot'ed environment.

1) I could chroot and then cd to /usr/src and then manually install the package.
2) I could chroot and then run the installation script from the proper directory.
3) What I want to do and what's giving me issues, is to issue a command similar to this:

Code:
chroot /root/me/here cd /usr/src
...and have it do the installation after changing to /usr/src.

However, the error that I get is:

Code:
chroot: cannot run command `cd': No such file or directory
I can cd just fine when I manually chroot, but, how can I cd to a directory right from the chroot command option? I can't even find the cd program so that I can hard code the command. (I'm guessing because it's a builtin?) Thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-20-2010, 01:57 PM   #2
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 129Reputation: 129
It does not make sense to do that, it wont CD at all. Your better to write a script and execute that script in the chroot instead of going command per command. "cd" is not a real command, it is a built in command of sh/dash/bash/zsh/ksh so you have to lauch bash and telling it to "cd", but it still does not make sense.

Code:
#!/bin/bash
#^^^ Very important here
cd /usr/src
your commands
 
2 members found this post helpful.
  


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
chroot: expect: command not found dbbolton Linux From Scratch 11 12-06-2009 07:33 PM
Problems with chroot command in Slax white-crow Linux - Newbie 11 11-07-2009 02:24 AM
Must Be Wrong chroot or CD command browser Linux - Newbie 4 02-10-2008 07:45 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 03:57 AM
wu-ftp help with chroot - ls command does not execute bock Linux - Software 2 09-18-2002 01:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:58 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