I am tasked with writing a simple shell along with these three commands: “nl”, “head”, “chroot”(with no parameters). I’ve written nl.c and head.c but I don’t know where to start with the chroot.c. I’ve read what chroot does, googled some documentation and to me as a beginner this is complicated.
Any advice on this matter?
chrootwithout an argument just prints an error message. You can useprintffor that.Otherwise, chroot calls
chroot,chdir("/")and then executes a shell with one of theexec*functions.