How to run a .run file as root?
Solution 1
You need to do two things; both from a Terminal prompt:
- Change to the directory where you have the
.run
file stored. - Type:
chmod 755 filename.run
- Type:
sudo ./filename.run
The above commands will make the file executable and will launch the executable with root-level permissions.
Solution 2
Add the command "sudo" before the command. For example: sudo blah.sh
After you enter your password the command will run as root. Be careful to verify the trustworthiness of a package or command before running it with sudo.
Solution 3
root
is the master account in Ubuntu; every account has limited privileges but the root
account has no limitations. The reason for hiding root
is that in most cases you don't need root access. The analog in Windows would be having to authenticate when you want to install a driver; in Ubuntu you have to be root or have root privileges.
There are two ways for you to get access as root. You can type:
sudo <whatever-command>
and Ubuntu will ask you for your password and then execute that command as root.
OR
sudo su
, where you'll input your own password and then you will become root (i.e. you will be logged in as root).
I prefer the latter because it gives me more control; sometimes running a command just as root isn't enough, but doing it this way can be more dangerous (i.e. you could accidentally cause more damage).
I recommend trying the first way. And then trying the second way if that doesn't work. Just make sure you get out of root after you're done (i.e. type exit
after you're finished doing what you need to do as root).
Reymmer
Hello I'm a bit new to Ubuntu. I have knowledge on computers in general, so I know about things like dual booting and Partitions, and usb devices and Processors and your basic kind of stuff. But it's the actual OS that I'm new to. So, I will be asking a LOT of questions, and answering very few if any.
Updated on September 18, 2022Comments
-
Reymmer over 1 year
I downloaded a .run file for a Nvidia driver, but when I run it in the terminal it tells me it must be run as root.
I'm a complete noob and I barely even know what root is. I think it's somewhere around the equivalent of admin in windows.
Well, I got the file to run but it turns out that the driver will not recognize my card. I've heard about other problems with Nvidia cards not working right with 64 bit versions of 12.04.
-
thomasrutter almost 12 yearsIf you are, as you say, a complete noob, perhaps there is a better and easier way to do what you're doing. Are you simply trying to install the Nvidia driver? There is a point and click interface for that - look for "Additional drivers" under your system settings. If you have already tried that, could you let us know, and what went wrong?
-
Takkat almost 12 yearsIn case your are not so experienced with Ubuntu I would go a step further and like to discourage you from installing graphic drivers other than through the methods mentioned above.
-
desgua almost 12 yearsAlso if you want to test a beta driver, look at this askubuntu.com/questions/131150/…
-
Reymmer almost 12 yearsThere are no drivers under the "additional drivers" setting. I don't need to be discouraged, how else will I learn but through trial and error? Beta driver? I will look into that. I have plenty of time to re-install ubuntu thousands of times.
-
Sos about 11 years@neon_overload, I know this is an old thread, but I would just like to point out that I had to install "Additional drivers" from the Ubuntu Software Center, as it didn't show up by default
-
-
notkevin almost 12 yearsPS you really should read help.ubuntu.com/community/RootSudo
-
Deepak Verma almost 12 yearsBut the file ran OK, obviously, so why confuse him with unnecessary steps? Also, you should specify that "filename" is not to be typed literally, but substitutes for the name of the .run file.
-
Reymmer almost 12 yearsIt's alright, I understood it. I had to google some things but in the end it was fine.
-
Eliah Kagan almost 12 years
sudo -s
is widely considered preferable tosudo su
(though this may have more to do with elegance than anything else). To get aroot
shell that behaves like an actualroot
login, usesudo -i
instead. (This is similar tosudo su -
.) Also,logout
will not work to get out of asudo su
shell, because such a shell is not a login shell. You need to useexit
instead. -
Eliah Kagan almost 12 yearsOf course, if the command is
./blah.sh
then to run it as root you would dosudo ./blah.sh
, rather thansudo blah.sh
(which would only runblah.sh
if it's in the$PATH
). -
Avery Chan almost 12 years@EliahKagan Cool! I didn't know about
sudo -i
/-s
. Good point onexit
, I mistyped that. I'll edit the entry above. Can you explain whysudo -s
is more "elegant"? -
Eliah Kagan almost 12 yearsSure, but first some background so that the explanation can be beneficial to others.
su
andsudo
are two separate mechanisms for running a command as a some user, who may be different from the user invoking them. (If not otherwise specified,su
andsudo
will run--or attempt to run--the command asroot
.) Sincesu
authenticates with the target user's password, and password authentication forroot
is turned off by default (and not recommended or officially supported) in Ubuntu, you cannot usesu
to becomeroot
, butroot
can certainly usesu
to become some other user. -
Eliah Kagan almost 12 years
sudo
andsu
are both capable of running a single command.sudo
does this by default andsu
does this when given the-c
flag. They are also both capable of starting a shell.sudo
does this when given the-s
flag (or-i
to simulate an initial login shell), andsu
does this by default (or when given the-
flag, to simulate such a login shell). When you runsudo su
, you are becomingroot
withsudo
, and then becoming root again as root (i.e.,root
su
-ing to itself), to start a shell. It's more elegant to just "change" identity once and start the login shell... -
Eliah Kagan almost 12 years...which is what
sudo -s
(orsudo -i
) accomplishes.su -c 'sudo ...'
(with...
replaced by a command) would be similarly inelegant. Commands likesudo bash
are considered a bit inelegant for a different, related reason--sudo
has the-s
and-i
flags to start a shell however you like, so one may as well use them. While these ways are inelegant (and subtly different in their effects from the suggestedsudo -s
andsudo -i
), they are not actually bad and they work fine, so it's OK to go on using them if you wish. -
MUY Belgium over 10 yearsAttention, must possibly use gksudo for graphicals...
-
Soren A about 7 yearsIn Ubuntu root isn't setup for login / su with password as default, so the above wont work out of the box.