unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Running emacs as root
@ 2004-01-07 18:45 Ted Weatherly
  2004-01-07 19:33 ` Henrik Enberg
  0 siblings, 1 reply; 5+ messages in thread
From: Ted Weatherly @ 2004-01-07 18:45 UTC (permalink / raw)


Hi,

To run emacs as root, I normally 'su' then 'emacs'.  I'd like to
create a script to simplify this.  I try:

sudo -u root /bin/sh -c "emacs"

...and I'm able to edit files as root.  But when I run a shell within
emacs, my prompt displays as if I'm a regular user (i.e. it shows as
"/tmp> " but I want "/tmp# ").  So it appears as if emacs is using the
.profile of the regular user.   How do I fix this?  Perhaps there is a
better way to launch emacs as root?

Thanks.
-Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running emacs as root
  2004-01-07 18:45 Running emacs as root Ted Weatherly
@ 2004-01-07 19:33 ` Henrik Enberg
  2004-01-08  3:54   ` Ted Weatherly
  0 siblings, 1 reply; 5+ messages in thread
From: Henrik Enberg @ 2004-01-07 19:33 UTC (permalink / raw)


tbonemp3@yahoo.com (Ted Weatherly) writes:

> To run emacs as root, I normally 'su' then 'emacs'.  I'd like to
> create a script to simplify this.  I try:
>
> sudo -u root /bin/sh -c "emacs"
>
> ...and I'm able to edit files as root.  But when I run a shell within
> emacs, my prompt displays as if I'm a regular user (i.e. it shows as
> "/tmp> " but I want "/tmp# ").  So it appears as if emacs is using the
> .profile of the regular user.   How do I fix this?  

sudo doesn't change your environment, you'd have to use su for that.

> Perhaps there is a better way to launch emacs as root?

I use tramp.el (see http://savannah.nongnu.org/projects/tramp/) to open
files as root with sudo within the running emacs.  When tramp is
installed simply do "C-x f /sudo:root@localhost:/path/to/file".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running emacs as root
  2004-01-07 19:33 ` Henrik Enberg
@ 2004-01-08  3:54   ` Ted Weatherly
  2004-01-08 23:36     ` Micha Feigin
  2004-01-11  1:11     ` gebser
  0 siblings, 2 replies; 5+ messages in thread
From: Ted Weatherly @ 2004-01-08  3:54 UTC (permalink / raw)


Is there a way to change my environment while executing a command?

Henrik Enberg <henrik.enberg@home.se> wrote in message news:<8765fnr1ti.fsf@home.se>...
> tbonemp3@yahoo.com (Ted Weatherly) writes:
> 
> > To run emacs as root, I normally 'su' then 'emacs'.  I'd like to
> > create a script to simplify this.  I try:
> >
> > sudo -u root /bin/sh -c "emacs"
> >
> > ...and I'm able to edit files as root.  But when I run a shell within
> > emacs, my prompt displays as if I'm a regular user (i.e. it shows as
> > "/tmp> " but I want "/tmp# ").  So it appears as if emacs is using the
> > .profile of the regular user.   How do I fix this?  
> 
> sudo doesn't change your environment, you'd have to use su for that.
> 
> > Perhaps there is a better way to launch emacs as root?
> 
> I use tramp.el (see http://savannah.nongnu.org/projects/tramp/) to open
> files as root with sudo within the running emacs.  When tramp is
> installed simply do "C-x f /sudo:root@localhost:/path/to/file".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running emacs as root
  2004-01-08  3:54   ` Ted Weatherly
@ 2004-01-08 23:36     ` Micha Feigin
  2004-01-11  1:11     ` gebser
  1 sibling, 0 replies; 5+ messages in thread
From: Micha Feigin @ 2004-01-08 23:36 UTC (permalink / raw)


On Wed, Jan 07, 2004 at 07:54:27PM -0800, Ted Weatherly wrote:
> Is there a way to change my environment while executing a command?
> 

You can append the environment setting on the commend line, for example

<var>=<value> <command>

will run <command> with <var>=<value> in its environment.

> Henrik Enberg <henrik.enberg@home.se> wrote in message news:<8765fnr1ti.fsf@home.se>...
> > tbonemp3@yahoo.com (Ted Weatherly) writes:
> > 
> > > To run emacs as root, I normally 'su' then 'emacs'.  I'd like to
> > > create a script to simplify this.  I try:
> > >
> > > sudo -u root /bin/sh -c "emacs"
> > >
> > > ...and I'm able to edit files as root.  But when I run a shell within
> > > emacs, my prompt displays as if I'm a regular user (i.e. it shows as
> > > "/tmp> " but I want "/tmp# ").  So it appears as if emacs is using the
> > > .profile of the regular user.   How do I fix this?  
> > 
> > sudo doesn't change your environment, you'd have to use su for that.
> > 
> > > Perhaps there is a better way to launch emacs as root?
> > 
> > I use tramp.el (see http://savannah.nongnu.org/projects/tramp/) to open
> > files as root with sudo within the running emacs.  When tramp is
> > installed simply do "C-x f /sudo:root@localhost:/path/to/file".
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Running emacs as root
  2004-01-08  3:54   ` Ted Weatherly
  2004-01-08 23:36     ` Micha Feigin
@ 2004-01-11  1:11     ` gebser
  1 sibling, 0 replies; 5+ messages in thread
From: gebser @ 2004-01-11  1:11 UTC (permalink / raw)



If you're running Unix/Linux you first need to make it okay for others
(even root) to use your X.  So do "xhost +127.0.0.1" (without the
quotes).  You'll need to do that only the first time.  Then do

su - -c "export DISPLAY=0:0;emacs"

The first dash says 'use root's environment'.  The '-c ...' specifies 
the command to run; in the double quotes is actually two commands 
(separated by the semi-colon), but Unix/Linux doesn't care.  

You could also alias this whole command to something easier to remember 
if you want.


hth,
ken


At 19:54 (UTC-0800) on 7 Jan 2004 Ted Weatherly said:

= Is there a way to change my environment while executing a command?
= 
= Henrik Enberg <henrik.enberg@home.se> wrote in message news:<8765fnr1ti.fsf@home.se>...
= > tbonemp3@yahoo.com (Ted Weatherly) writes:
= > 
= > > To run emacs as root, I normally 'su' then 'emacs'.  I'd like to
= > > create a script to simplify this.  I try:
= > >
= > > sudo -u root /bin/sh -c "emacs"
= > >
= > > ...and I'm able to edit files as root.  But when I run a shell within
= > > emacs, my prompt displays as if I'm a regular user (i.e. it shows as
= > > "/tmp> " but I want "/tmp# ").  So it appears as if emacs is using the
= > > .profile of the regular user.   How do I fix this?  
= > 
= > sudo doesn't change your environment, you'd have to use su for that.
= > 
= > > Perhaps there is a better way to launch emacs as root?
= > 
= > I use tramp.el (see http://savannah.nongnu.org/projects/tramp/) to open
= > files as root with sudo within the running emacs.  When tramp is
= > installed simply do "C-x f /sudo:root@localhost:/path/to/file".
= _______________________________________________
= Help-gnu-emacs mailing list
= Help-gnu-emacs@gnu.org
= http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
= 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-11  1:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-07 18:45 Running emacs as root Ted Weatherly
2004-01-07 19:33 ` Henrik Enberg
2004-01-08  3:54   ` Ted Weatherly
2004-01-08 23:36     ` Micha Feigin
2004-01-11  1:11     ` gebser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).