Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Ward, ajmitch, qbi, Eric Carvalho Jan 28 '13 at 0:14

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.