Way to avoid having to type sudo password each time?

  • Follow


Hi,

I'm using Mac 10.6.3.  I'm a sudo user.  On my machine, I frequently
need to restart my Apache web server, and hwen I pop open my terminal
and type

> sudo /usr/sbin/apachectl restart

I'm prompted for a password immediately after.  Is there a way I can
avoid having to type my password and just enter the command above?

Thanks, - Dave
0
Reply laredotornado (854) 4/26/2010 4:37:28 PM

laredotornado wrote:

> I'm prompted for a password immediately after.  Is there a way I can
> avoid having to type my password and just enter the command above?

sudo bash

you enter the poassword once, and then you have a subprocess which is
always in sudo mode.

Or you can enable the "root" account <ducking because I know the
comments that will be made> and you can then login in as "root" and not
need to use sudo.
0
Reply JF 4/26/2010 4:52:00 PM


In article 
<28ac1987-ba86-4ce3-b562-3981cae0ff7a@h16g2000prf.googlegroups.com>,
 laredotornado <laredotornado@zipmail.com> wrote:

> Hi,
> 
> I'm using Mac 10.6.3.  I'm a sudo user.  On my machine, I frequently
> need to restart my Apache web server, and hwen I pop open my terminal
> and type
> 
> > sudo /usr/sbin/apachectl restart
> 
> I'm prompted for a password immediately after.  Is there a way I can
> avoid having to type my password and just enter the command above?

Make an entry in the sudoers file. If you type "man sudoers" and "man 
visudo" in a terminal window, it'll tell you what to do.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689
0
Reply Tim 4/26/2010 5:11:02 PM

On 04/26/2010 12:37 PM, laredotornado wrote:
> I'm prompted for a password immediately after.  Is there a way I can
> avoid having to type my password and just enter the command above?

sudo su

You'll need to enter the password once. Then enter all the commands to 
your heart's content. Exit when finished.

-- 
Nothing exists except atoms and empty space; everything else is opinion.
-- Democritus
0
Reply johnny 4/26/2010 5:57:16 PM

In message <4bd5c4b0$0$9587$c3e8da3@news.astraweb.com> 
  JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
> laredotornado wrote:

>> I'm prompted for a password immediately after.  Is there a way I can
>> avoid having to type my password and just enter the command above?

> sudo bash

Preferred way to do this is sudo -s

> Or you can enable the "root" account <ducking because I know the
> comments that will be made> and you can then login in as "root" and not
> need to use sudo.

There is no reason to enable the root account (none) and many reasons
not to.

-- 
I have as much authority as the Pope, I just don't have as many people who
believe it. 
0
Reply Lewis 4/26/2010 6:26:38 PM

In article 
<28ac1987-ba86-4ce3-b562-3981cae0ff7a@h16g2000prf.googlegroups.com>,
 laredotornado <laredotornado@zipmail.com> wrote:

> Hi,
> 
> I'm using Mac 10.6.3.  I'm a sudo user.  On my machine, I frequently
> need to restart my Apache web server, and hwen I pop open my terminal
> and type
> 
> > sudo /usr/sbin/apachectl restart
> 
> I'm prompted for a password immediately after.  Is there a way I can
> avoid having to type my password and just enter the command above?
> 
> Thanks, - Dave

The most secure way to do this is by editing the /etc/sudoers file to 
contain an entry that allows NOPASSWD access for particular commands.  
For instance, if you wanted to allow NOPASSWD access for the user named 
dave to the apachectl command, you would add entries similar to this:

Cmnd_Alias     APACHECTL = /usr/sbin/apachectl
dave           ALL = NOPASSWD:APACHECTL

For more information, read the sudo and sudoers manual pages.

-- 
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
0
Reply Jolly 4/26/2010 6:28:29 PM

In article <4bd5c4b0$0$9587$c3e8da3@news.astraweb.com>,
 JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:

> laredotornado wrote:
> 
> > I'm prompted for a password immediately after.  Is there a way I can
> > avoid having to type my password and just enter the command above?
> 
> sudo bash
> 
> you enter the poassword once, and then you have a subprocess which is
> always in sudo mode.

The drawback to doing this is that it's an extra step you have to take 
each occasion you want to run commands as root/admin. A better 
alternative is to add an appropriate entry in /etc/sudoers (as I have 
described in another reply) that allows you to run that command without 
a password prompt as the particular user account you use daily. This 
saves you that extra step of switching to the root/admin account each 
occasion.

> Or you can enable the "root" account <ducking because I know the
> comments that will be made> and you can then login in as "root" and not
> need to use sudo.

Overkill. 'Nuff said.

-- 
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
0
Reply Jolly 4/26/2010 6:30:59 PM

On Apr 26, 1:28=A0pm, Jolly Roger <jollyro...@pobox.com> wrote:
> In article
> <28ac1987-ba86-4ce3-b562-3981cae0f...@h16g2000prf.googlegroups.com>,
>
> =A0laredotornado <laredotorn...@zipmail.com> wrote:
> > Hi,
>
> > I'm using Mac 10.6.3. =A0I'm a sudo user. =A0On my machine, I frequentl=
y
> > need to restart my Apache web server, and hwen I pop open my terminal
> > and type
>
> > > sudo /usr/sbin/apachectl restart
>
> > I'm prompted for a password immediately after. =A0Is there a way I can
> > avoid having to type my password and just enter the command above?
>
> > Thanks, - Dave
>
> The most secure way to do this is by editing the /etc/sudoers file to
> contain an entry that allows NOPASSWD access for particular commands. =A0
> For instance, if you wanted to allow NOPASSWD access for the user named
> dave to the apachectl command, you would add entries similar to this:
>
> Cmnd_Alias =A0 =A0 APACHECTL =3D /usr/sbin/apachectl
> dave =A0 =A0 =A0 =A0 =A0 ALL =3D NOPASSWD:APACHECTL
>
> For more information, read the sudo and sudoers manual pages.
>
> --
> Send responses to the relevant news group rather than email to me.
> E-mail sent to this address may be devoured by my very hungry SPAM
> filter. Due to Google's refusal to prevent spammers from posting
> messages through their servers, I often ignore posts from Google
> Groups. Use a real news client if you want me to see your posts.
>
> JR

This is the solution I went with and it worked perfectly.  5 stars. -
Dave
0
Reply laredotornado 4/26/2010 9:11:19 PM

On Apr 26, 4:11=A0pm, laredotornado <laredotorn...@zipmail.com> wrote:
> On Apr 26, 1:28=A0pm, Jolly Roger <jollyro...@pobox.com> wrote:
>
>
>
> > In article
> > <28ac1987-ba86-4ce3-b562-3981cae0f...@h16g2000prf.googlegroups.com>,
>
> > =A0laredotornado<laredotorn...@zipmail.com> wrote:
> > > Hi,
>
> > > I'm usingMac10.6.3. =A0I'm a sudo user. =A0On my machine, I frequentl=
y
> > > need to restart my Apache web server, and hwen I pop open my terminal
> > > and type
>
> > > > sudo /usr/sbin/apachectl restart
>
> > > I'm prompted for a password immediately after. =A0Is there a way I ca=
n
> > > avoid having to type my password and just enter the command above?
>
> > > Thanks, - Dave
>
> > The most secure way to do this is by editing the /etc/sudoers file to
> > contain an entry that allows NOPASSWD access for particular commands. =
=A0
> > For instance, if you wanted to allow NOPASSWD access for the user named
> > dave to the apachectl command, you would add entries similar to this:
>
> > Cmnd_Alias =A0 =A0 APACHECTL =3D /usr/sbin/apachectl
> > dave =A0 =A0 =A0 =A0 =A0 ALL =3D NOPASSWD:APACHECTL
>
> > For more information, read the sudo and sudoers manual pages.
>
> > --
> > Send responses to the relevant news group rather than email to me.
> > E-mail sent to this address may be devoured by my very hungry SPAM
> > filter. Due to Google's refusal to prevent spammers from posting
> > messages through their servers, I often ignore posts from Google
> > Groups. Use a real news client if you want me to see your posts.
>
> > JR
>
> This is the solution I went with and it worked perfectly. =A05 stars. -
> Dave

I need to revive this thread because I just switched to a new machine
(still a Mac 10.6.3), but even though my /etc/sudoers file contains


# User privilege specification
root    ALL=3D(ALL) ALL
%admin  ALL=3D(ALL) ALL
davea   ALL =3D NOPASSWD:APACHECTL

I'm still being prompted for my password when trying to restart
apache ...

davea-mbp2:~ davea$ sudo /usr/sbin/apachectl restart
Password:

Any ideas what I may be missing?  Thanks, - Dave
0
Reply laredotornado 5/3/2010 4:26:09 PM

In article 
<a53b3aec-5305-4384-af44-63120890ae91@g39g2000pri.googlegroups.com>,
 laredotornado <laredotornado@zipmail.com> wrote:

> Any ideas what I may be missing?  Thanks, - Dave

You'll have to include httpd in your sudoers file, I guess; apachectl is 
a shell script that invokes it.
-- 
Very old woody beets will never cook tender.
  -- Fannie Farmer
0
Reply Warren 5/3/2010 5:42:04 PM

Replace the 'APACHECTL' below for 'ALL'

# User privilege specification
root ALL=3D(ALL) ALL
%admin ALL=3D(ALL) ALL
davea ALL =3D NOPASSWD:APACHECTL
0
Reply linuxmant 12/24/2010 8:01:11 AM

On 2010-05-03 12:26:09 -0400, laredotornado said:

> On Apr 26, 4:11�pm, laredotornado <laredotorn...@zipmail.com> wrote:
>> On Apr 26, 1:28�pm, Jolly Roger <jollyro...@pobox.com> wrote:
>> 
>> 
>> 
>>> In article
>>> <28ac1987-ba86-4ce3-b562-3981cae0f...@h16g2000prf.googlegroups.com>,
>> 
>>> �laredotornado<laredotorn...@zipmail.com> wrote:
>>>> Hi,
>> 
>>>> I'm usingMac10.6.3. �I'm a sudo user. �On my machine, I frequently
>>>> need to restart my Apache web server, and hwen I pop open my terminal
>>>> and type
>> 
>>>>> sudo /usr/sbin/apachectl restart
>> 
>>>> I'm prompted for a password immediately after. �Is there a way I can
>>>> avoid having to type my password and just enter the command above?
>> 
>>>> Thanks, - Dave
>> 
>>> The most secure way to do this is by editing the /etc/sudoers file to
>>> contain an entry that allows NOPASSWD access for particular commands. �
>>> For instance, if you wanted to allow NOPASSWD access for the user named
>>> dave to the apachectl command, you would add entries similar to this:
>> 
>>> Cmnd_Alias � � APACHECTL = /usr/sbin/apachectl
>>> dave � � � � � ALL = NOPASSWD:APACHECTL
>> 
>>> For more information, read the sudo and sudoers manual pages.
>> 
>>> --
>>> Send responses to the relevant news group rather than email to me.
>>> E-mail sent to this address may be devoured by my very hungry SPAM
>>> filter. Due to Google's refusal to prevent spammers from posting
>>> messages through their servers, I often ignore posts from Google
>>> Groups. Use a real news client if you want me to see your posts.
>> 
>>> JR
>> 
>> This is the solution I went with and it worked perfectly. �5 stars. -
>> Dave
> 
> I need to revive this thread because I just switched to a new machine
> (still a Mac 10.6.3), but even though my /etc/sudoers file contains
> 
> 
> # User privilege specification
> root    ALL=(ALL) ALL
> %admin  ALL=(ALL) ALL
> davea   ALL = NOPASSWD:APACHECTL
> 
> I'm still being prompted for my password when trying to restart
> apache ...
> 
> davea-mbp2:~ davea$ sudo /usr/sbin/apachectl restart
> Password:
> 
> Any ideas what I may be missing?  Thanks, - Dave

case in point...

0
Reply A 12/24/2010 11:47:25 AM

On 2010-04-26 14:30:59 -0400, Jolly Roger said:

> In article <4bd5c4b0$0$9587$c3e8da3@news.astraweb.com>,
>  JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
> 
>> laredotornado wrote:
>> 
>>> I'm prompted for a password immediately after.  Is there a way I can
>>> avoid having to type my password and just enter the command above?
>> 
>> sudo bash
>> 
>> you enter the poassword once, and then you have a subprocess which is
>> always in sudo mode.
> 
> The drawback to doing this is that it's an extra step you have to take
> each occasion you want to run commands as root/admin. A better
> alternative is to add an appropriate entry in /etc/sudoers (as I have
> described in another reply) that allows you to run that command without
> a password prompt as the particular user account you use daily. This
> saves you that extra step of switching to the root/admin account each
> occasion.
> 
>> Or you can enable the "root" account <ducking because I know the
>> comments that will be made> and you can then login in as "root" and not
>> need to use sudo.
> 
> Overkill. 'Nuff said.

Rule 37. There is no overkill. There is only 'Open fire' and 'Time to 
reload'. 
<http://store.schlockmercenary.com/PhotoGallery.asp?ProductCode=P%2DR37>

Loading up root may be extreme, but sometimes it's just simpler.

0
Reply A 12/24/2010 11:47:25 AM

In article 
<a53b3aec-5305-4384-af44-63120890ae91@g39g2000pri.googlegroups.com>,
 laredotornado <laredotornado@zipmail.com> wrote:

> On Apr 26, 4:11�pm, laredotornado <laredotorn...@zipmail.com> wrote:
> > On Apr 26, 1:28�pm, Jolly Roger <jollyro...@pobox.com> wrote:
> >
> >
> >
> > > In article
> > > <28ac1987-ba86-4ce3-b562-3981cae0f...@h16g2000prf.googlegroups.com>,
> >
> > > �laredotornado<laredotorn...@zipmail.com> wrote:
> > > > Hi,
> >
> > > > I'm usingMac10.6.3. �I'm a sudo user. �On my machine, I frequently
> > > > need to restart my Apache web server, and hwen I pop open my terminal
> > > > and type
> >
> > > > > sudo /usr/sbin/apachectl restart
> >
> > > > I'm prompted for a password immediately after. �Is there a way I can
> > > > avoid having to type my password and just enter the command above?
> >
> > > > Thanks, - Dave
> >
> > > The most secure way to do this is by editing the /etc/sudoers file to
> > > contain an entry that allows NOPASSWD access for particular commands. �
> > > For instance, if you wanted to allow NOPASSWD access for the user named
> > > dave to the apachectl command, you would add entries similar to this:
> >
> > > Cmnd_Alias � � APACHECTL = /usr/sbin/apachectl
> > > dave � � � � � ALL = NOPASSWD:APACHECTL
> >
> > > For more information, read the sudo and sudoers manual pages.
> >
> > > --
> > > Send responses to the relevant news group rather than email to me.
> > > E-mail sent to this address may be devoured by my very hungry SPAM
> > > filter. Due to Google's refusal to prevent spammers from posting
> > > messages through their servers, I often ignore posts from Google
> > > Groups. Use a real news client if you want me to see your posts.
> >
> > > JR
> >
> > This is the solution I went with and it worked perfectly. �5 stars. -
> > Dave
> 
> I need to revive this thread because I just switched to a new machine
> (still a Mac 10.6.3), but even though my /etc/sudoers file contains
> 
> 
> # User privilege specification
> root    ALL=(ALL) ALL
> %admin  ALL=(ALL) ALL
> davea   ALL = NOPASSWD:APACHECTL
> 
> I'm still being prompted for my password when trying to restart
> apache ...
> 
> davea-mbp2:~ davea$ sudo /usr/sbin/apachectl restart
> Password:
> 
> Any ideas what I may be missing?  Thanks, - Dave

How about the 'Cmnd_Alias'?

-- 
Tom Stiller

PGP fingerprint =  5108 DDB2 9761 EDE5 E7E3  7BDA 71ED 6496 99C0 C7CF
0
Reply Tom 12/24/2010 1:38:06 PM

In article <2010122406472590532-noneof@theabovenet>,
 A Non E Mouse <none.of@the.above.net> wrote:

> On 2010-04-26 14:30:59 -0400, Jolly Roger said:
> 
> > In article <4bd5c4b0$0$9587$c3e8da3@news.astraweb.com>,
> >  JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
> > 
> >> laredotornado wrote:
> >> 
> >>> I'm prompted for a password immediately after.  Is there a way I can
> >>> avoid having to type my password and just enter the command above?
> >> 
> >> sudo bash
> >> 
> >> you enter the poassword once, and then you have a subprocess which is
> >> always in sudo mode.
> > 
> > The drawback to doing this is that it's an extra step you have to take
> > each occasion you want to run commands as root/admin. A better
> > alternative is to add an appropriate entry in /etc/sudoers (as I have
> > described in another reply) that allows you to run that command without
> > a password prompt as the particular user account you use daily. This
> > saves you that extra step of switching to the root/admin account each
> > occasion.
> > 
> >> Or you can enable the "root" account <ducking because I know the
> >> comments that will be made> and you can then login in as "root" and not
> >> need to use sudo.
> > 
> > Overkill. 'Nuff said.
> 
> Rule 37. There is no overkill. There is only 'Open fire' and 'Time to 
> reload'. 
> <http://store.schlockmercenary.com/PhotoGallery.asp?ProductCode=P%2DR37>
> 
> Loading up root may be extreme, but sometimes it's just simpler.

Simpler and yet more dangerous, especially for those who are less 
experienced.

-- 
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.

JR
0
Reply Jolly 12/24/2010 5:25:39 PM

On 2010-12-24 12:25:39 -0500, Jolly Roger said:

> In article <2010122406472590532-noneof@theabovenet>,
>  A Non E Mouse <none.of@the.above.net> wrote:
> 
>> On 2010-04-26 14:30:59 -0400, Jolly Roger said:
>> 
>>> In article <4bd5c4b0$0$9587$c3e8da3@news.astraweb.com>,
>>> JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
>>> 
>>>> laredotornado wrote:
>>>> 
>>>>> I'm prompted for a password immediately after.  Is there a way I can
>>>>> avoid having to type my password and just enter the command above?
>>>> 
>>>> sudo bash
>>>> 
>>>> you enter the poassword once, and then you have a subprocess which is
>>>> always in sudo mode.
>>> 
>>> The drawback to doing this is that it's an extra step you have to take
>>> each occasion you want to run commands as root/admin. A better
>>> alternative is to add an appropriate entry in /etc/sudoers (as I have
>>> described in another reply) that allows you to run that command without
>>> a password prompt as the particular user account you use daily. This
>>> saves you that extra step of switching to the root/admin account each
>>> occasion.
>>> 
>>>> Or you can enable the "root" account <ducking because I know the
>>>> comments that will be made> and you can then login in as "root" and not
>>>> need to use sudo.
>>> 
>>> Overkill. 'Nuff said.
>> 
>> Rule 37. There is no overkill. There is only 'Open fire' and 'Time to
>> reload'.
>> <http://store.schlockmercenary.com/PhotoGallery.asp?ProductCode=P%2DR37>
>> 
>> Loading up root may be extreme, but sometimes it's just simpler.
> 
> Simpler and yet more dangerous, especially for those who are less
> experienced.

UNIX is extremely user-friendly. It's just picky about who its friends 
are. if you and UNIX are not friends then doing things in root can have 
Unexpected Results. This is why you become friends with UNIX before 
doing things in root, and why you have backups. Lots of backups. And 
why you turn root off again as soon as you're finished using it.

0
Reply A 12/24/2010 10:43:56 PM

16 Replies
1297 Views

(page loaded in 0.028 seconds)

Similiar Articles:


















7/23/2012 8:28:45 AM


Reply: