Review your favorite Linux distribution.
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 01-31-2005, 03:54 AM   #1
Registered: Oct 2004
Posts: 45

Rep: Reputation: 15
How 2 run commands having only root privilige in C if one knows the root password?

Suppose I have two accounts: root(obviously the administrator) and user1
Now user1 runs my program(in Qt/C++). This program contains some commands which can be used only by root user.After checking that it is not the root user who has logged in but someone else my program prompts the user to enter the password for root.After taking & verifying that it is the root password, i want that my program should be able to run those commands also.How can i do that?
Thanks in advance

Last edited by shivaligupta; 01-31-2005 at 03:56 AM.
Old 01-31-2005, 04:24 AM   #2
LQ Newbie
Registered: Nov 2003
Location: Dublin
Distribution: Slackware9.1
Posts: 28

Rep: Reputation: 15
instead of using your program to verify the user has root privelages, you should let the system do it... Use the "switch user" command su or sudo. For the latter, you can place the user in a file called "sudoers" and even name specific commands for which they have root access.
man su
man sudo for more information.
Hope this helps.


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
Root/User rights to Root commands? mrde50garfield Linux - Software 2 10-24-2006 05:42 AM
giving root privilage to ordinary user... skie_knite007 Programming 5 09-13-2005 09:03 AM
Cannot run basic commands unless Im logged on as root zwyrbla Linux - Newbie 4 08-22-2004 07:20 AM
Can't execute commands when logged in as ordinary user.... murphaph Linux - General 3 04-05-2004 05:23 PM
im in user mode and cant run hdparm and ifconfig commands, but if im root, i can. kublador Linux - Newbie 2 09-12-2003 08:27 AM > Forums > Non-*NIX Forums > Programming

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