On Sun, Mar 22, 2015 at 03:30:49AM -0400, German wrote

> Thanks, I decide to go with sudo on this one. However when I try
> to run it, it says: "Username is not in the sudoers file." Where is
> this file located and how can I add the user to it? Thanks

  Here's how it works.  "emerge -pv sudo" and decide whic USE flags you
need for your situation.  I use none of them.  The main config file is
/etc/sudoers  *DO NOT TOUCH THAT FILE*.  It'll get overwritten every
time that an update of sudo comes along.  sudo also reads files in its
"include directory", which defaults to /etc/sudoers.d/ which is where
you should put your stuff.  You can have multiple files in there, and
they will be executed in the same order that they sort.  *DO NOT EDIT
THESE FILES DIRECTLY WITH NANO/VIM/WHATEVER*.  Use the command...

visudo -f /etc/sudoers.d/filename

where "filename" is any legal file name.  visudo is a sudo feature that
* gets your default editor
* edits a *WORKING COPY* of the file you want to change
* after you exit the editor, it tests the file syntax
* if no sudo syntax errors are found it commits the file
* if syntax errors are found, it warns you, and allows you to back out

  I have a single file /etc/sudoers.d/001 but you can have several files
if you want.  The desktop's hostname is "d531" and my login is
"waltdnes".  Adjust correspondingly for your system...

waltdnes  d531 = (root) NOPASSWD: /sbin/poweroff
waltdnes  d531 = (root) NOPASSWD: /usr/sbin/hibernate
waltdnes  d531 = (root) NOPASSWD: /usr/bin/simple-mtpfs -o allow_other 
/home/waltdnes/tablet
waltdnes  d531 = (root) NOPASSWD: /usr/bin/fusermount -u /home/waltdnes/tablet
waltdnes  d531 = (root) NOPASSWD: /bin/cp -f /etc/ssmtp/295.ssmtp.conf 
/etc/ssmtp/ssmtp.conf
waltdnes  d531 = (root) NOPASSWD: /bin/cp -f /etc/ssmtp/teksavvy.ssmtp.conf 
/etc/ssmtp/ssmtp.conf
waltdnes  d531 = (root) NOPASSWD: /usr/bin/openrdate -n -s ca.pool.ntp.org
waltdnes  d531 = (root) NOPASSWD: /sbin/hwclock --systohc


  This format allows the user to run the command, if preceeded by
"sudo", and no password is required.  Note that the command must be
identical to what is set in /etc/sudoers.d/ e.g.

sudo /sbin/poweroff

  I usually launch it from a script in ~/bin to same a lot of typing,
and avoid typo errors.  For instance, to connect my tablet or smartphone
to directory ~/tablet, I have a script ~/bin/tabon

#!/bin/bash
sudo simple-mtpfs -o allow_other /home/waltdnes/tablet

  To disconnect from the device I have a script ~/bin/taboff

#!/bin/bash
sudo fusermount -u /home/waltdnes/tablet

  To sync my desktop's clock, I have a script ~/bin/settime

#!/bin/bash
date
/usr/bin/sudo /usr/bin/openrdate -n -s ca.pool.ntp.org
/usr/bin/sudo /sbin/hwclock --systohc
date

  I have a dialup ISP (295.ca) as emergency backup in case my broadband
ISP (teksavvy.com) service goes down.  ISP's only let logged in users
connect to the standard outbound port.  So I need to change the
/etc/ssmtp/ssmtp.conf file to point to the approprite ISP's server.  My
dialup script is...

#!/bin/bash
sudo /bin/cp -f /etc/ssmtp/295.ssmtp.conf /etc/ssmtp/ssmtp.conf
sudo /usr/sbin/pon u295.ca

  My "dialdown" script is...

#!/bin/bash
/usr/bin/sudo /usr/sbin/poff
/usr/bin/sudo /bin/cp -f /etc/ssmtp/teksavvy.ssmtp.conf /etc/ssmtp/ssmtp.conf



-- 
Walter Dnes <waltd...@waltdnes.org>
I don't run "desktop environments"; I run useful applications

Reply via email to