[ESS] Fwd: How does one start R within Emacs/ESS with root privileges?

Steven McKinney smckinney at bccrc.ca
Wed Sep 7 21:55:52 CEST 2011


Hi Karl,

In my opinion the Microsoft decision to essentially make
an operating system that treats each user as a root user
was a major design flaw.  I see at my work plenty of people
using root on a unix box because things appear to get done
more easily and the experience is more like working on a
Microsoft windows box.

Excessive use of the root account pretty much always leads 
to problems down the road.  Most of the reasons people have
given to me about why they chose to use root to do "X"
ended up being related to the issue that they did not know
how to properly configure things - properly set up their
PATH variable, properly set up user accounts with appropriate
group memberships, and properly set up the read/write/execute
privileges associated with each file and directory.

Learning how to configure your Ubuntu system will pay off
with hours of saved time later, as you will not have to 
reinstall improperly configured software, manage piles
of inappropriately copied files and directories etc.

Not to mention the potential security problems that running
everything as root enables.  Running R as root, all you
have to do is install some dodgy package and the author
of that package (or the hacker that re-authored that
package) will be able to instruct your machine to do pretty
much anything.

Use of the root account should always be a *last resort*,
when for reasons of necessity dictated by the operating
system the root account is the only way to do the job properly.
Always configure user accounts, files and directories 
appropriately and attempt to do as much as possible without 
the root account.

It is easier to add privileges to items installed by
a non-root user than to remove excessive privileges
set in place when doing everything as "root".

Here's how I configure a Unix box so all users can install
R packages:

- Make sure at a minimum that your user account is a member
of the group "users".  

- Use the "visudo" command to edit your "sudoers" file and
add your account to the sudoers list.  Then you can use the
sudo command for certain commands that do require root-level
privilege, but just for that command.  Try to use sudo to
get a command done before going "root".

- Install R to a friendlier location such as /opt/apps/R/R-2.13.1
rather than the default /usr/bin/R and /usr/lib64/R to allow easier
maintenance of each installation of R.

- Find the "library" directory on your Ubuntu machine where R installs
its packages.  Make sure that directory and all of its contents
are members of group "users", and set read/write/execute permissions
for group so that any member of the group "users" can modify the
contents of the library directory.  For example:

$ sudo chown -R root:users /usr/lib64/R/library # Make sure group "users" can access directory and contents
$ sudo chmod -R g+rwx /usr/lib64/R/library # Make sure members of "users" can read, write and execute

or

$ chown karl:users /opt/apps/R/R-2.13.1/library
$ chmod g+rwx /opt/apps/R/R-2.13.1/library

Once the group membership of accounts and group
properties of files/directories is properly set up,
installing new packages is straight forward without
using the root account.  Maintenance is easier, and
security is maintained, and this will minimize issues
down the road. 


Best of luck with your new unix-based machine - once
you climb up that learning curve a bit, you will look
back at the bizarre Windows world and see why so many
people have worked so hard to get their operating system
back.  I see many open-source re-implementations of unix
systems but I haven't seen as much effort to re-implement
Windows as open-source.  Microsoft keeps trying to
add more unix-like features to Windows (witness the bizarre
set up in Windows 7 to have users and administrators, and
hidden copies of directories...) because the many smart
people who set up the unix operating system did so many
things right.


Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre



> -----Original Message-----
> From: ess-help-bounces at r-project.org [mailto:ess-help-bounces at r-project.org] On Behalf Of Karl Brand
> Sent: September-07-11 7:27 AM
> To: Paul Johnson; ESS-help at stat.math.ethz.ch
> Subject: Re: [ESS] Fwd: How does one start R within Emacs/ESS with root privileges?
> 
> Thanks a lot Paul.
> 
> Your answer implies you either maintain a user library that doesn't
> require root privileges &/or you don't use ESS to install/maintain
> system wide packages.
> 
> Is it the former? Is this how most ESS/R user's work - from their own
> separate user library?
> 
> I just want to minimise issues down the road (presently unknown
> unknowns) by hearing opinions from the experienced .
> 
> cheers, Karl
> 
> 
> On 2011-09-07 16:01, Paul Johnson wrote:
> 
> >
> > I've never tried to run R as root inside emacs.
> >
> > But I just tested and this does work:
> >
> > # sudo emacs whatever.R
> >
> > after that, R is running as root
> >
> >
> > pj
> >
> >> tia,
> >>
> >> Karl
> >>
> >> -------- Original Message --------
> >> Subject: How does one start R within Emacs/ESS with root privileges?
> >> Date: Wed, 07 Sep 2011 14:19:36 +0200
> >> From: Karl Brand<k.brand at erasmusmc.nl>
> >> To: ESS-help at stat.math.ethz.ch
> >>
> >> <Reposted from r-help at r-project.org>
> >>
> >> Esteemed ESS Users&  Devs,
> >>
> >> How does one start R within Emacs/ESS with root privileges?
> >>
> >> I tried without success:
> >>
> >>> M-x sudo R
> >>
> >> Why i'm motivated to do so:
> >>
> >> It seems logical to me, as the only user of the PC, to keep my R library
> >> consolidated in the universal library rather than splitting into
> >> universal and user libraries. Hence the desire to run R as root.
> >>
> >> In addition, it's nice to be able to install packages 'on the fly' when
> >> and as needed and not need to launch a separate R session (as root) in
> >> the terminal just to install a package.
> >>
> >> Migrating from windows, i'm completey new to linux (ubuntu) and am
> >> seeing for myself if Emacs/ESS is as good as its purported to be. So
> >> maybe my motivation is nonsensical to expereinced ESS/R users. If so i'd
> >> really appreciate tips on efficient package installation/maintenance
> >> using Emacs/ESS.
> >>
> >> TIA,
> >>
> >> karl
> >>
> >
> 
> --
> Karl Brand <k.brand at erasmusmc.nl>
> Department of Genetics
> Erasmus MC
> Dr Molewaterplein 50
> 3015 GE Rotterdam
> P +31 (0)10 704 3455 | F +31 (0)10 704 4743 | M +31 (0)642 777 268
> 
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list