Results 1 to 5 of 5
I'm a New Linux User and I wanna Know
How to login as SU on Script
I Mean wanna Design a Script but some commands on it Need the SU ...
- 01-07-2011 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 3
How to login as SU on Script
I'm a New Linux User and I wanna Know
How to login as SU on Script
I Mean wanna Design a Script but some commands on it Need the SU Privilege How Can I do it




Last edited by MikeTbob; 01-09-2011 at 01:56 PM. Reason: Changed font size
- 01-08-2011 #2Just Joined!
- Join Date
- Dec 2010
- Location
- India
- Posts
- 45
u can write a expect script in that case
- 01-09-2011 #3Just Joined!
- Join Date
- Nov 2010
- Posts
- 3
ok i'll give you an example
if i wanna add a User to the system , I'll use adduser command
but to use this command i must login as SU
here what i wanna do
i wanna run a script whose login as SU and do the Command
- 01-11-2011 #4
It is possible with certain tools like Perl to create an SUID script...
SUID programs, in case you don't know, run as the user who owns the program file when they are executed:
Programs like "passwd" which need to perform privileged operations (read and write the shadow password file, in this case) must have the authority to do so. That is granted by the "suid" bit set on the program file. When you run /usr/bin/passwd, the "passwd" program gets root privileges.Code:$ ls -l /usr/bin/passwd -rwsr-xr-x 1 root root 41296 Jul 24 2009 /usr/bin/passwd
You can set the SUID bit on a script file - but Linux will not honor it. The reason for that is because it's highly dangerous. There are all kinds of ways you can subvert the operation of a script - exporting a different PATH or LD_PRELOAD variable, for instance - rather than allow people to compromise their systems with inherently dangerous SUID scripts, the decision was made to simply disable the feature.
Perl works around this: if you have a Perl script that has the SUID bit set, the Perl interpreter will note this and attempt to run the script via the suid-perl mechanism. This enables some additional safety checks (input validation stuff, etc.) - so if you want to create an SUID utility but don't want to compile something, Perl is an option.
- 01-12-2011 #5Just Joined!
- Join Date
- Nov 2010
- Posts
- 3
thank you so much for your explication I'm So glade to Know you
Last edited by Hamada_wolv; 01-12-2011 at 12:36 PM.


Reply With Quote