Jump to content

How to run a program as administrator in linux?

im coming from windows and i want to open the program "QT creator" as admin but don't know how to. i have tried this tutorial and it didnt work. Im able to open programs like firefox using this method but the program Qt creator wont open. it just keep loading and then nothing happens. in the case of firefox, that opens almost instantly. i have tried gksudo from terminal as well.the case is same. firefox opens up but QT doesnt. any help would be appreciated. thank u    

 

Link to comment
Share on other sites

Link to post
Share on other sites

The first question is why do you want to run the program as Root?

 

Linux is very different to Windows and installing/running apps as Root can cause some major headaches with permissions.

 

As a general rule you shouldn't install or run anything as Root unless specifically instructed to do so.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Master Disaster said:

The first question is why do you want to run the program as Root?

 

Linux is very different to Windows and installing/running apps as Root can cause some major headaches with permissions.

 

As a general rule you shouldn't install or run anything as Root unless specifically instructed to do so.

i have to run a terminal command from that qt creator which u have to run with the command sudo. in terminal i could give password but in this as im running through c++ im not sure if this is possible. there may be a way but i want to run the qt creator as root and see if i can get over the problem that way

Link to comment
Share on other sites

Link to post
Share on other sites

If you really need to run that specific command as root, change the exact command to look like "sudo command"

If you want to run the entire application as root, either open it in a terminal using sudo and just move that terminal out of your way, or use gksu which will run your application as root and give you a graphical prompt for your password.

Keep in mind this is not the way you should run application, very few applications need to run as root. Since you are mentioning QT Creator, is this by any chance a "make install" step? If though this step is not necessary to execute your application. If it is another command, consider the fact that there is something seriously wrong with that command if it needs to run as root. 

Again running an unknown application as root is a very very bad idea you should not be doing it.

Link to comment
Share on other sites

Link to post
Share on other sites

On 12/11/2017 at 4:08 PM, Master Disaster said:

The first question is why do you want to run the program as Root?

 

Linux is very different to Windows and installing/running apps as Root can cause some major headaches with permissions.

 

As a general rule you shouldn't install or run anything as Root unless specifically instructed to do so.

Are you linux user?

How do YOU install programs on linux without root LOL?

 

To OP

You can run firefox with command "firefox" and you can run firefox with root with this command "sudo firefox" that's it. Although you should not run every program with root.

 

Computer users fall into two groups:
those that do backups
those that have never had a hard drive fail.

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, mate_mate91 said:

Are you linux user?

How do YOU install programs on linux without root LOL?

 

To OP

You can run firefox with command "firefox" and you can run firefox with root with this command "sudo firefox" that's it. Although you should not run every program with root.

 

Just for the sake of argument Flatpak and Snappy should not require root, i have not tested them so i have no idea if they do. You can also obviously run most applications by installing them locally but that is just not the point of the discussion :)

Anyway i get your point, you need root it is just that very few commands should ever be executed as root and you should be careful which ones you run

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, mate_mate91 said:

Are you linux user?

How do YOU install programs on linux without root LOL?

 

To OP

You can run firefox with command "firefox" and you can run firefox with root with this command "sudo firefox" that's it. Although you should not run every program with root.

 

Are you a Linux user?

 

There's a difference between installing a program with a local account using SU or SUDO and installing a program as the user ROOT.

 

Using SU or SUDO keeps the app permissions tied to the user account issuing the command while giving it ROOT access while installing as the user ROOT ties the program permissions to the user ROOT and any local account will not be able to run it.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Master Disaster said:

There's a difference between installing a program with a local account using SU or SUDO and installing a program as the user ROOT.

 

Using SU or SUDO keeps the app permissions tied to the user account issuing the command while giving it ROOT access while installing as the user ROOT ties the program permissions to the user ROOT and any local account will not be able to run it.

 

Not really, running an installer using su -c is equivalent to changing to a root account and running the application from there. I think sudo has the same effect, it does not preserve permissions, it will run the given command as root.

 ghaith@ghaith-laptop  ~   laptop  sudo mkdir test
[sudo] password for ghaith: 
 ghaith@ghaith-laptop  ~   laptop  cd test
 ghaith@ghaith-laptop  ~/test   laptop  ls -lah
total 8.0K
drwxr-xr-x  2 root   root   4.0K Dec 12 22:41 .
drwxr--r-- 73 ghaith ghaith 4.0K Dec 12 22:41 ..
 ghaith@ghaith-laptop  ~/test   laptop  touch file
touch: cannot touch 'file': Permission denied
 ✘ ghaith@ghaith-laptop  ~/test   laptop  

 

Link to comment
Share on other sites

Link to post
Share on other sites

8 hours ago, g el said:

Not really, running an installer using su -c is equivalent to changing to a root account and running the application from there. I think sudo has the same effect, it does not preserve permissions, it will run the given command as root.


 ghaith@ghaith-laptop  ~   laptop  sudo mkdir test
[sudo] password for ghaith: 
 ghaith@ghaith-laptop  ~   laptop  cd test
 ghaith@ghaith-laptop  ~/test   laptop  ls -lah
total 8.0K
drwxr-xr-x  2 root   root   4.0K Dec 12 22:41 .
drwxr--r-- 73 ghaith ghaith 4.0K Dec 12 22:41 ..
 ghaith@ghaith-laptop  ~/test   laptop  touch file
touch: cannot touch 'file': Permission denied
 ✘ ghaith@ghaith-laptop  ~/test   laptop  

 

I guess it's distro dependant but that simply can't be true on Ubuntu/Debian.

 

I use SUDO apt-get install to install most things and afterwards my local account is capable of running them just fine.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, Master Disaster said:

I guess it's distro dependant but that simply can't be true on Ubuntu/Debian.

 

I use SUDO apt-get install to install most things and afterwards my local account is capable of running them just fine.

Yes, but you're installing as Root. SUDO = Super User (root) Do, in other words: root, please run this command. This doesn't involve running the program you're installing at all.

PC Specs - AMD Ryzen 7 5800X3D MSI B550M Mortar - 32GB Corsair Vengeance RGB DDR4-3600 @ CL16 - ASRock RX7800XT 660p 1TBGB & Crucial P5 1TB Fractal Define Mini C CM V750v2 - Windows 11 Pro

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, NelizMastr said:

Yes, but you're installing as Root. SUDO = Super User (root) Do, in other words: root, please run this command. This doesn't involve running the program you're installing at all.

I'm well aware of what SUDO means and does.

 

Look at it this way, if I were to login to Ubuntu as the ROOT user then install an application all the files associated with that app would have their permissions set to ROOT (specifically file ownership permissions). If I then logged out of ROOT and back in as me said app MIGHT not run properly, or at all, because I don't own the files associated with it.

 

If I login as me then SUDO install an app at the end I'm the owner of the files and I can run said app from my account without using SUDO.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

36 minutes ago, Master Disaster said:

I'm well aware of what SUDO means and does.

 

Look at it this way, if I were to login to Ubuntu as the ROOT user then install an application all the files associated with that app would have their permissions set to ROOT (specifically file ownership permissions). If I then logged out of ROOT and back in as me said app MIGHT not run properly, or at all, because I don't own the files associated with it.

 

If I login as me then SUDO install an app at the end I'm the owner of the files and I can run said app from my account without using SUDO.

4

No, that's not how that works. Running apt-get as root or in sudo is the same thing, what apt-get will do, or what dpkg will do really is to extract the content of the deb file and place it relative to the / folder, now it needs root because as a normal user you cannot write to the / folder. It will then set the permissions of the files to +x for non-group members, meaning anyone can execute the file, this is done in all cases, try to apt-get install in root and normal it is the same

if you do your installation by hand then you have to worry about that, the package manager will always make sure appropriate groups can execute the software

 

Here's another example:

 ghaith@brainiac  ~   master  whoami
ghaith
 ghaith@brainiac  ~   master  sudo whoami
[sudo] password for ghaith: 
root
 ghaith@brainiac  ~   master  

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, g el said:

No, that's not how that works. Running apt-get as root or in sudo is the same thing, what apt-get will do, or what dpkg will do really is to extract the content of the deb file and place it relative to the / folder, now it needs root because as a normal user you cannot write to the / folder. It will then set the permissions of the files to +x for non-group members, meaning anyone can execute the file, this is done in all cases, try to apt-get install in root and normal it is the same

if you do your installation by hand then you have to worry about that, the package manager will always make sure appropriate groups can execute the software

 

Here's another example:


 ghaith@brainiac  ~   master  whoami
ghaith
 ghaith@brainiac  ~   master  sudo whoami
[sudo] password for ghaith: 
root
 ghaith@brainiac  ~   master  

 

Interesting, thing is I've had exactly that happen to me a few years back when I was still learning the ropes. I wonder if it was me that made a mistake then but I remember having a huge headache with an app because I installed it as root and it set permissions to root so only the root user could run it.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×