chroot используется для создания jail и изоляции процессов, а также для сборки пакетов методом debootstrap.
Командой chroot с указанием каталога запускается механизм, создающий систему директорий в этом каталоге идентичную той, что существует в корне . Команда выполняется только от имени суперпользователя.
Например chroot /mnt
bin boot dev etc home lib lib64 lost+found media mnt opt proc root run sbin srv sys tmp usr var
lost+found
chroot: failed to run command ‘/bin/bash’: No such file or directory
Как устранить ошибку «chroot: failed to run command ‘/bin/bash’: No such file or directory»
Ошибка возникает из-за отсутствия в каталоге, который делается корневым необходимых библиотек и бинарных файлов. Исправить ошибку можно скопировав файлы хост системы в chroot
Нужны библиотеки скопированы, сейчас создаем каталог для бинарных файлов и полностью копируем их в этот каталог
Теперь ошибок быть не должно
bin lib lib64 usr
Каталогов нет, но их можно очень просто создать и подмонтировать, однако стоит учитывать, что в chroot в этом случае будут использоваться каталоги из хост системы
Например, для /proc
Теперь доступно управление процессами
PID TTY TIME CMD
21294 ? 00:00:00 bash
21673 ? 00:00:00 bash
21689 ? 00:00:00 ps
Выполнив ps aux можно получить доступ к процессам всей системы, а не только chroot. Это может являться угрозой безопасности. chroot стоит использовать для сборки пакетов под разные системы на одном хосте или для тестирования какого-либо ПО, также он нужен чтобы запуститься со съемного носителя когда на основной машине неработоспособен загрузчик.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto | Site FAQ | Sitemap | Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
![]() |
Introduction to Linux — A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author’s experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. I’m learning through this tutorial to learn bash scripts to automate a few tasks for me. I’m connecting to a server using putty. The script, located in . /Documents/LOG , is: And I executed the following for read/write/execute permissions Then, when I enter ./my_script , I’m getting the error given in the title. Some similar questions wanted to see these, so I think they might help: I tried adding current directory to PATH , but that doesn’t work.. 11 Answers 11I have seen this issue when creating scripts in Windows env and then porting over to run on a Unix environment. Try running dos2unix on the script: Or just rewrite the script in your Unix env using vi and test. Unix uses different line endings so can’t read the file you created on Windows. Hence it is seeing ^M as an illegal character. If you want to write a file on Windows and then port over, make sure your editor is set to create files in UNIX format. In notepad++ in the bottom right of the screen, it tells you the document format. By default, it will say DosWindows . To change it go to
|