How to run a .run file as root?

96,444

Solution 1

You need to do two things; both from a Terminal prompt:

  1. Change to the directory where you have the .run file stored.
  2. Type: chmod 755 filename.run
  3. 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).

Share:
96,444
Reymmer
Author by

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, 2022

Comments

  • Reymmer
    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. driver run as root

    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
      thomasrutter almost 12 years
      If 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
      Takkat almost 12 years
      In 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
      desgua almost 12 years
      Also if you want to test a beta driver, look at this askubuntu.com/questions/131150/…
    • Reymmer
      Reymmer almost 12 years
      There 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
      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
    notkevin almost 12 years
    PS you really should read help.ubuntu.com/community/RootSudo
  • Deepak Verma
    Deepak Verma almost 12 years
    But 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
    Reymmer almost 12 years
    It's alright, I understood it. I had to google some things but in the end it was fine.
  • Eliah Kagan
    Eliah Kagan almost 12 years
    sudo -s is widely considered preferable to sudo su (though this may have more to do with elegance than anything else). To get a root shell that behaves like an actual root login, use sudo -i instead. (This is similar to sudo su -.) Also, logout will not work to get out of a sudo su shell, because such a shell is not a login shell. You need to use exit instead.
  • Eliah Kagan
    Eliah Kagan almost 12 years
    Of course, if the command is ./blah.sh then to run it as root you would do sudo ./blah.sh, rather than sudo blah.sh (which would only run blah.sh if it's in the $PATH).
  • Avery Chan
    Avery Chan almost 12 years
    @EliahKagan Cool! I didn't know about sudo -i/-s. Good point on exit, I mistyped that. I'll edit the entry above. Can you explain why sudo -s is more "elegant"?
  • Eliah Kagan
    Eliah Kagan almost 12 years
    Sure, but first some background so that the explanation can be beneficial to others. su and sudo 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 and sudo will run--or attempt to run--the command as root.) Since su authenticates with the target user's password, and password authentication for root is turned off by default (and not recommended or officially supported) in Ubuntu, you cannot use su to become root, but root can certainly use su to become some other user.
  • Eliah Kagan
    Eliah Kagan almost 12 years
    sudo and su are both capable of running a single command. sudo does this by default and su 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), and su does this by default (or when given the - flag, to simulate such a login shell). When you run sudo su, you are becoming root with sudo, 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
    Eliah Kagan almost 12 years
    ...which is what sudo -s (or sudo -i) accomplishes. su -c 'sudo ...' (with ... replaced by a command) would be similarly inelegant. Commands like sudo 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 suggested sudo -s and sudo -i), they are not actually bad and they work fine, so it's OK to go on using them if you wish.
  • MUY Belgium
    MUY Belgium over 10 years
    Attention, must possibly use gksudo for graphicals...
  • Soren A
    Soren A about 7 years
    In Ubuntu root isn't setup for login / su with password as default, so the above wont work out of the box.