Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
2  
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 at 18:40
2  
and there is a reason why they call it homework ;) – Rinzwind Jan 27 at 18:45
1  
You cannot exec("/bin"). Only executable files can be executed, /bin is a directory. Try exec("/bin/ls"). – Andrea Corbellini Jan 27 at 19:42
[For clearness: with exec() I mean the family of functions that start with that prefix.] – Andrea Corbellini Jan 27 at 19:48

closed as not constructive by Rinzwind, The Lord of Time, ajmitch, qbi, Eric Carvalho Jan 28 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 specific 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, see the FAQ for guidance.

2 Answers

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.