Welcome to the most active Linux Forum on the web.
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-06-2002, 12:12 AM   #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, 06: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 05:40 AM
how to get root privilege in a script jpan Linux - General 5 01-07-2005 03:46 PM
Insufficient Privilege instead of Root Password Request buckberger Linux - Security 3 12-25-2004 09:00 PM
Temp root privilege in program? ZX_SA Programming 1 07-22-2004 09:14 AM
Why root has no privilege to access some directories ymei Linux - General 4 10-08-2003 09:14 AM

All times are GMT -5. The time now is 02:39 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