Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7660355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:27:16+00:00 2026-05-31T13:27:16+00:00

I know that use the command chroot in linux need some files or directories

  • 0

I know that use the command “chroot” in linux need some files or directories such as usr, bin and so on. But when I use the function chroot() in C, do I need these files?

Here is my code, which “hw.out” is a binary file which just print “Hello, world”. I compiled it and run it as root, but it was failed to print “Hello, world”. What else should I do? Thank you!

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    int result = chroot(".");

    if(result == 0)
        printf("Chroot Succese.\n");

    char *arrays[]={"./hw.out",NULL};
    execvp("./hw.out", arrays);
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:27:17+00:00Added an answer on May 31, 2026 at 1:27 pm

    execvp is most likely failing, probably with ENOENT: no such file or directory, if hw.out is a dynamically linked executable.

    For that to work, all the libraries required by hw.out need to be findable in the chrooted environment.

    Try linking hw.out statically, and it should work. (And add error checking after execvp to see what errno is set to after the call if it returns.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that I can use cmp, diff, etc to compare two files, but
I know that I have to use: rdtsc. The measured function is deterministic but
I know that some dll files have to be registered with the regsvr32 command.
We know that we can use a concept Java Package, but I just wanted
I know that I can use following command to extract a single file to
I know that I can use the git diff command to check the changes,
I'm going to create some command line tools that make use of some large
I know that I can use the terminal and the system-profiler command to determine
I know that you can use a dummy int parameter on operator++ and operator--
I know that I can use $('#myId').load('aPage.html'); to load a page into an element,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.