sudo without having to type a password

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
lilcreep

sudo without having to type a password

Post by lilcreep »

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.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
walcken

Re: sudo without having to type a password

Post by walcken »

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
Habitual

Re: sudo without having to type a password

Post by Habitual »

/etc/rc.local
User avatar
Roken
Level 5
Level 5
Posts: 737
Joined: Fri Nov 19, 2010 4:55 pm
Location: Newport, S Wales

Re: sudo without having to type a password

Post by Roken »

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

Code: Select all

echo "password" | sudo -S command
Kernel Linux Tex 5.12.14-zen1-1-zen, XFCE
Arch
Dual GTX1070 8Gb
AMD Ryzen 1800X
32Gb RAM
walcken

Re: sudo without having to type a password

Post by walcken »

Habitual wrote:/etc/rc.local
That's exactly what I said :roll:
Locked

Return to “Scripts & Bash”