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 have a file in the root directory which I want to open for editing in my QT application. Generally we use "sudo (editor) filepath" to open the file with roots permissions. But i want to achieve this in my c++ QT application. Any kind of help is appreciable. Thank you.

share|improve this question
sudo (editor) filepath runs (editor) with Administrator privileges passing filepath to it as a parameter. So sudo my-c-application would run my-c-application as with the required privileges. Or if your application has a GUI gksudo my-c-application. Replace my-c-application with the name of your program – Warren Hill May 10 '13 at 17:52
up vote 0 down vote accepted

as I know you can do it in two ways.

  1. Remove or disable the root prompt when ever we are trying to access the root mounted dir. But the pros & cons are mentioned here very clearly.

  2. Everytime if you will access the same directory/file then you can change file permission to that directory as everyone access& modify it. for that consideration read this page.

so choose what best suits you.

hope that helps a bit.

share|improve this answer
The second option looks interesting. But is it possible to give permission to a file such that only my application can access it when the application is ran by any user. but those any user can't modify the file unless they are using the application. – Aces Smart May 10 '13 at 17:02
No you can't make it for application but you can make it for current login user . Look at the link I gave you. – Raja May 10 '13 at 17:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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