Take the 2-minute tour ×

I am doing a homework assignment for a class, and part of it is designing our own shell and read and write in low level. After forking, it needs to execute a command that a user inputs. When the execute tries to do it, it says that there is permission denied. I think getting access to the /bin while exevc("/bin/", argv) is the problem. Is there a way for my created shell get access to the /bin? Chmodding /bin is not allowed, according to outputs from the terminal.

share|improve this question

closed as not constructive by Rinzwind, Thomas W., ajmitch, qbi, Eric Carvalho Jan 28 '13 at 0:14


Please post the relevant section of your code. Which language are you using? Since this is a programming question, you might have better luck on Stack Overflow. –  Flimm Jan 27 '13 at 18:40
and there is a reason why they call it homework ;) –  Rinzwind Jan 27 '13 at 18:45
You cannot exec("/bin"). Only executable files can be executed, /bin is a directory. Try exec("/bin/ls"). –  Andrea Corbellini Jan 27 '13 at 19:42
[For clearness: with exec() I mean the family of functions that start with that prefix.] –  Andrea Corbellini Jan 27 '13 at 19:48

2 Answers 2

Have you tried running your program as root?

It's in general a bad idea to futz with the permissions outside of your home directory if you don't know exactly what you are doing. If there are files in places like /bin that only root can execute, it is probably for security reasons.

That said, be careful running your scripts as root too, as bugs in code can lead to breaking your OS (i.e don't do your experimentation with rm as root).

share|improve this answer

I would advise NOT doing this on a live filesystem. If anything, you should try this in a VM and ONLY in a VM.

That said, everything gradi3nt said applies.

share|improve this answer
