sudo without having to type a password

Forum rules
Before you post please read how to get help
lilcreep
Level 1
Level 1
Posts: 3
Joined: Fri Dec 09, 2011 6:15 pm

sudo without having to type a password

Postby lilcreep » Wed Jan 11, 2012 4:39 pm

Hi,

my notebook with hybrid graphics starts with on-chip-graphics in use, but both graphic chips powered.
To safe battery power, I want to use a script, executed on startup:

Code: Select all

sudo -s
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
exit
exit


Problem is, that this script will ask for my user-password.
How can I do thatfully automatic, without any thing bugging me.

walcken
Level 1
Level 1
Posts: 3
Joined: Mon Jan 09, 2012 7:51 pm

Re: sudo without having to type a password

Postby walcken » Wed Jan 11, 2012 4:50 pm

Try to put this line :

Code: Select all

echo OFF > /sys/kernel/debug/vgaswitcheroo/switch


before the line

Code: Select all

exit 0


in the file at the following path : /etc/rc.local

User avatar
Habitual
Level 12
Level 12
Posts: 4011
Joined: Sun Nov 21, 2010 8:31 pm
Location: Youngstown, Ohio

Re: sudo without having to type a password

Postby Habitual » Wed Jan 11, 2012 4:52 pm

/etc/rc.local
Do you realize how hard it is for me to explain to people that I know you?

User avatar
Roken
Level 5
Level 5
Posts: 740
Joined: Fri Nov 19, 2010 4:55 pm
Location: Oldham, UK
Contact:

Re: sudo without having to type a password

Postby Roken » Wed Jan 11, 2012 5:01 pm

You can run a command with sudo in a script if you want:

Code: Select all

echo "password" | sudo -S command
Kernel Linux Tex 3.2.2-1 (64 bit) xfce , burg
Arch
ATI Radeon HD 4670, 1GB
OSS4
AMD Phenom II X4 (965BE) @ 3.6 Ghz (Overclocked)
8Gb RAM
Image

walcken
Level 1
Level 1
Posts: 3
Joined: Mon Jan 09, 2012 7:51 pm

Re: sudo without having to type a password

Postby walcken » Wed Jan 11, 2012 8:46 pm

Habitual wrote:/etc/rc.local


That's exactly what I said :roll:


Return to “Scripts & Bash”

Who is online

Users browsing this forum: No registered users and 1 guest