From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 17C60138CC5 for ; Mon, 23 Mar 2015 01:40:06 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 60BEFE08A4; Mon, 23 Mar 2015 01:39:59 +0000 (UTC) Received: from ironport2-out.teksavvy.com (ironport2-out.teksavvy.com [206.248.154.181]) by pigeon.gentoo.org (Postfix) with ESMTP id 5271CE084D for ; Mon, 23 Mar 2015 01:39:58 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgYFAGvvdVTO+J4+/2dsb2JhbAA3gVOhb4EIgXUBAQQBOhwoCwshDQEBBBIPBSU3iACiEYt2CiEBBA8QCAICAoNeAw4BAxkDDhIBBYI5YwSNVYdhhW2IQIRYgTk X-IPAS-Result: AgYFAGvvdVTO+J4+/2dsb2JhbAA3gVOhb4EIgXUBAQQBOhwoCwshDQEBBBIPBSU3iACiEYt2CiEBBA8QCAICAoNeAw4BAxkDDhIBBYI5YwSNVYdhhW2IQIRYgTk X-IronPort-AV: E=Sophos;i="5.01,1,1400040000"; d="scan'208";a="114232413" Received: from 206-248-158-62.dsl.teksavvy.com (HELO waltdnes.org) ([206.248.158.62]) by ironport2-out.teksavvy.com with SMTP; 22 Mar 2015 21:39:56 -0400 Received: by waltdnes.org (sSMTP sendmail emulation); Sun, 22 Mar 2015 21:39:56 -0400 From: "Walter Dnes" Date: Sun, 22 Mar 2015 21:39:56 -0400 To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] How to poweroff the system from user? Message-ID: <20150323013956.GA29737@waltdnes.org> References: <20150321152656.a82a84b3e8a32c8b68554548@gmail.com> <20150322030659.ec90006302b19a7fe9775e1e@gmail.com> <6466269.mY7mxbMetF@navi> <20150322033049.aab2319694dadd92fb2bcff8@gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150322033049.aab2319694dadd92fb2bcff8@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Archives-Salt: fe2f191f-b408-4139-ad27-5aa552bcea30 X-Archives-Hash: a41801d99c866391ed500bf844d100fd 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 I don't run "desktop environments"; I run useful applications