From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: gebser@speakeasy.net Newsgroups: gmane.emacs.help Subject: Re: Running emacs as root Date: Sat, 10 Jan 2004 20:11:39 -0500 (EST) Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: Reply-To: gebser@speakeasy.net NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1073784029 15993 80.91.224.253 (11 Jan 2004 01:20:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Jan 2004 01:20:29 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 11 02:20:24 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AfUH9-0002ne-01 for ; Sun, 11 Jan 2004 02:20:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AfVDe-0001LL-7L for geh-help-gnu-emacs@m.gmane.org; Sat, 10 Jan 2004 21:20:50 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AfVDK-0001KI-AC for help-gnu-emacs@gnu.org; Sat, 10 Jan 2004 21:20:30 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AfVCn-00014O-SH for help-gnu-emacs@gnu.org; Sat, 10 Jan 2004 21:20:28 -0500 Original-Received: from [216.254.0.204] (helo=mail4.speakeasy.net) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AfVCn-00014G-Gx for help-gnu-emacs@gnu.org; Sat, 10 Jan 2004 21:19:57 -0500 Original-Received: (qmail 3016 invoked from network); 11 Jan 2004 01:11:46 -0000 Original-Received: from dsl093-011-017.cle1.dsl.speakeasy.net (HELO heidegger.mousecar.net) ([66.93.11.17]) (envelope-sender ) by mail4.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 11 Jan 2004 01:11:46 -0000 Original-To: help-gnu-emacs@gnu.org In-Reply-To: X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:15917 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15917 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 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 =