My question is asking regarding a specific observation that I would like to understand.
I just tried to install the package rJava in R and failed even though I prefaced the installation as suggested by the manual with:
sudo R CMD javareconf
Then I came across this comment:
Using sudo and running as root are not exactly the same thing. – Jon7
Desparate as I was I tried it:
sudo su
R CMD javareconf
And to my surprise I suddenly could install that package.
Sorry for the lenghty introduction but I wanted to give you a context to prevent answers like here. The question does not aim at specifically the described observation – rather at those "things" in general on Ubuntu.
My question is: How could this be possible? What is the difference between sudo X and runnding X as root?
Best Answer
That's somewhat too broad to explain it will end with conclusion like in a link that you linked to your question, but I'll try something more fullfilled maybe it will give you some answers.
sudo
("substitute user do") allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands asroot
or another user while providing an audit trail of the commands and their arguments.Sudo
is an alternative tosu
for running commands asroot
. Unlikesu
, which launches aroot
shell that allows all further commandsroot
access,sudo
instead grants temporary privilege escalation to a single command. By enablingroot
privileges only when needed,sudo
usage reduces the likelihood that a typo or a bug in an invoked command will ruin the system.Sudo
can also be used to run commands as other users; additionally,sudo
logs all commands and failed access attempts for security auditing.More detailed info about
Root Sudo
can be found on Official Ubuntu Documentation