Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-05-2002, 11:12 PM   #1
Registered: Dec 2001
Location: thunder bay, on, Canada
Distribution: Windows vista & Ubuntu
Posts: 113

Rep: Reputation: 15
How to get root privilege in program using c?

In my program,I want to write sth in system dirs,but i donot have enough privilege.
I think obtainning root privilege maybe the only way.But how to do?
Old 04-06-2002, 05:27 AM   #2
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
for the program to have root privelages it must either be executed as root or be setuid root. being setuid root means that the program binary is owned by root, and executes as root even when a normal user runs it. to make and executable setuid root do this:

chown root executable
chmod a+xs executable

obviously you have to do those commands as root. i'm not sure if that's the only way of getting root permissions for your program, but it's pretty standard for programs that need root privelages but want to be run by ordinary users.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute root-privilege programs in KDE autostart? rylan76 Linux - Software 3 07-31-2005 04:40 AM
how to get root privilege in a script jpan Linux - General 5 01-07-2005 02:46 PM
Insufficient Privilege instead of Root Password Request buckberger Linux - Security 3 12-25-2004 08:00 PM
Temp root privilege in program? ZX_SA Programming 1 07-22-2004 08:14 AM
Why root has no privilege to access some directories ymei Linux - General 4 10-08-2003 08:14 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration