How to run programs as root from the launcher in Linux

Last update: 15th October 2026
  • Root offers full control, but Ubuntu and other distributions keep it disabled by default to reduce risks.
  • Sudo allows you to elevate privileges on a case-by-case basis and keeps a record of who executes each command.
  • For graphical applications, there are helpers such as kdesu, gksu, gksudo, or pkexec, which can be used in .desktop launchers.
  • Security depends on using least privileges, avoiding untrusted scripts, and auditing elevated access.

Systems engineer managing servers in a modern data center.

In Windows, many people are used to pressing Shift+Enter or Shift+left-click to open a program with elevated privileges from the Start menu. In Linux, this isn't always straightforward, because security relies on root, sudo, and graphical helpers , and each desktop environment has its own tools. Even so, there are fairly simple ways to launch applications as root from a launcher, a shortcut, or the applications menu, although it's important to understand what doing so entails.

The key is that the root user has absolute control of the system , and modern distributions, especially Ubuntu and its derivatives, typically disable direct login. Therefore, it's not common to log in as root, but rather to elevate privileges occasionally using `sudo` or a graphical program that prompts for the password. If we want a launcher icon to launch an app with those privileges, we'll have to modify the command it executes or create a specific launcher.

What does it really mean to run something as root?

System administration workstation with multiple monitors displaying Linux terminals.

In Linux, root is the account with UID 0 and unlimited privileges . It can read, modify, or delete any file, install software, change kernel configurations, and control processes belonging to any user. This makes it an incredibly powerful tool, but also a huge risk if used carelessly. A simple typo with `rm` or `mv` can render the system unusable, and a malicious script executed as root can install backdoors, modify security measures, or steal data with virtually no trace.

In Ubuntu, the root account has no default password and direct login is not allowed. The philosophy is that you work with your regular user account and use `sudo` for specific tasks . `sudo` essentially means running a command as another user, usually root, after authenticating with your own password if you belong to the `sudo` group. This limits the amount of time you are exposed and keeps a record of who did what.

However, in very specific situations, such as recovering a damaged system, working in restricted environments, or configuring services that require persistent access, you might consider enabling root temporarily. The general recommendation is to disable it again as soon as the need arises. The less time you spend as root, the better for the stability and security of the machine.

Risks of using root without caution

One of the most obvious dangers is the accidental deletion of vital files . As root, there are no permission restrictions; a command like `sudo rm -rf /` can wipe the system without warning. There's also usually no recycle bin for these deletions, so recovery may require complex forensic tools or even a complete system reinstallation.

Another risk is running untrusted scripts. If you run code downloaded from any site with elevated privileges, you're essentially giving it the keys to your house . Even if the script seems harmless, it could contain destructive instructions or install malware with root privileges. Therefore, it's advisable to review the code, use official sources, check checksums, and test it in a virtual machine or container before running it in production.

  Linux patches for RAS support on Qualcomm platforms

There's also a traceability issue. When you use `sudo`, the system logs the command, the user who issued it, and the time to `/var/log/auth.log`, `/var/log/secure`, or `journalctl` . If you log in directly as root, everything appears as root, and you lose the ability to know which individual made each change. In environments with multiple administrators or ISO 27001, PCI DSS, or other auditing standards, this lack of traceability is a significant weakness.

Ways to obtain privileges from the terminal

Screenshot detail of Ubuntu terminals showing system logs and process monitoring.

The most common and recommended way is to precede a specific command with `sudo`. For example, to update packages, restart a service, or edit a protected file, `sudo` will ask for your user password, not the root password, and after authenticating you, it will execute the command with elevated privileges. If you need to run it as a different user, you can use `sudo -u username command` . And if you realize you forgot to use `sudo`, you can repeat the last command with `sudo !! `.

When you're going to perform several administrative tasks in a row, it can be convenient to open a temporary root shell. `sudo -i` simulates a full root login, loads the root environment, and places you in the home directory. `sudo su` or `sudo su -` also work, although `sudo -i` is usually more reliable. To exit this session, simply type `exit`. It's not advisable to leave a root shell open unattended.

The `su` command, on the other hand, switches users. `su - root` or simply `su -` also adopt the environment variables of the target user, while `su root` or `su` without the hyphen retains part of the previous environment. This difference explains errors like `command not found`: administrative commands are usually located in `/usr/local/sbin`, `/usr/sbin`, and `/sbin`, paths that don't always appear in a regular user's PATH. If you use `su` without the hyphen, you'll have to type the full path or switch to `su -` to inherit the root PATH.

If you want to enable a password for root, you can do so with `sudo passwd root` . Ubuntu discourages this, but technically allows root to have a password. To lock the account, use `sudo passwd -l root` , and to unlock it, use `sudo passwd -u root`. In SSH, direct root access is controlled by `PermitRootLogin` in `/etc/ssh/sshd_config`. It's safest to keep it set to `no` or, at most, `prohibit-password` to allow only SSH passwords. Afterward, you need to restart the SSH service.

Configure sweaters accurately

The `/etc/sudoers` file defines who can use `sudo` and for what purpose. It's best not to edit it manually; the correct approach is to use `sudo visudo` , which locks the file and checks the syntax before saving. The basic rule takes the form `host user=(target_user)`. For example, `bob ALL=(ALL) ALL` allows `bob` to execute any command as root on any machine. Groups can also be used, such as `%admin ALL=(ALL) ALL`.

  Liquorix kernel in Linux: optimized kernel for desktop and gaming

To grant finer permissions, aliases are used. `User_Alias ​​ADMINS = alice, bob` groups users, and `Cmnd_Alias ​​LOCATE = /usr/sbin/updatedb` groups commands. Then, `ADMINS ALL = LOCATE` is used so that those users can only execute those commands. Aliases like `NETWORKING` can be created for commands such as `route`, `ifconfig`, `ping`, `iptables`, etc. This applies the principle of least privilege without granting full root access to anyone.

The NOPASSWD option allows you to run certain commands without a password, for example, `pi ALL=(ALL)`. NOPASSWD: ALL. This is convenient, but dangerous if abused. Furthermore, every use of `sudo` is logged, which helps audit access and troubleshoot problems. If something breaks, reviewing these logs can indicate which recent change caused the failure.

Launching graphical applications as root from the launcher

View of a Linux terminal showing the file listing of the root directory /.

For programs with a graphical interface, simply using `sudo` doesn't usually work well because there's no terminal to prompt for the password. This is where graphical helpers come in . In KDE, there's `kdesu` : if you know which command launches the application, you can run `kdesu that_command`. The `Run Command` option in the KDE menu also allows you to launch an application as another user by entering their credentials. In GNOME and GTK environments , `gksu` and `gksudo` were widely used ; these are frontends for `sudo` or `su`. For example, `gksu synaptic` or `gksudo gparted` open the app and ask for the password.

In modern systems, gksu is either discouraged or deprecated. Its usual alternative is pkexec , based on PolicyKit, which allows programs to run with privileges according to defined policies. Many current launchers use pkexec for administrative tasks. The idea is the same: the user doesn't have to open a terminal, but the system validates authorization in a controlled manner.

To create a shortcut in the launcher, you edit a .desktop file . The `Exec` line is the key. If you want it to run as root, you can use something like `Exec=gksu /path/to/program`, `Exec=kdesu /path/to/program`, or `Exec=pkexec /path/to/program`. If you use `sudo` directly, you'll need the launcher to have `Terminal=true` or configure a graphical askpass. You can also try pressing Alt+F2 and typing the helper and the program name, for example, `gksu synaptic`. In KDE, `kdesu synaptic` or the option to run as another user performs a similar function.

There's a classic alternative called consolehelper , a wrapper for GUI applications. You create a symbolic link, for example, /usr/bin/xterm-root pointing to /usr/sbin/consolehelper. Then you configure PAM by creating /etc/pam.d/xterm-root with the auth, account, and session inclusions from config-util. Next, you define /etc/security/console.apps/xterm-root with USER=root and PROGRAM=/usr/bin/xterm. When you run xterm-root, consolehelper prompts for PAM authentication and launches xterm as root. If you encounter an "Xlib connection to :0.0 refused by server" error, running xhost local:root might help.

In any case, opening graphical applications as root has drawbacks: it mixes environment variables, can break the session bus, affect Wayland or X11, and create root-owned files in your home directory. It's best to use it only for specific administrative tools and close them as soon as you're finished. Don't browse the internet or open suspicious documents as root , because any exploit would inherit full privileges.

Common examples of tasks that require root access

Many everyday operations require elevated privileges. Managing packages with apt, zypper, dnf, or yum often requires sudo. For example, `sudo apt update` , `sudo apt install firefox`, or `sudo zypper install docker-ce`. The same applies to system services: `sudo systemctl restart apache2`, `sudo systemctl restart ssh`, or `sudo systemctl restart nginx`. To modify user accounts, use `sudo usermod`, and to change file ownership, use `sudo chown`. Editing critical configurations, such as `/etc/ssh/sshd_config`, also requires root privileges if done with nano, vim, or gedit.

  How to repair GRUB without a LiveCD step by step

You don't need `sudo` for commands that only read information or don't modify the system, such as `zypper repos` or `systemctl status NetworkManager`. Using `sudo` for everything out of habit is bad practice. The sensible thing to do is to elevate privileges only when the task requires it and then switch back to the normal user as soon as possible.

Best practices when working with elevated privileges

Close-up of a server rack with blue lighting in a data center.

The principle of least privilege should guide everything. Use `sudo` for individual commands whenever possible, avoid persistent root shells unless absolutely necessary, and exit as soon as you're finished. Don't run scripts from unknown sources as root; review the code beforehand, download from official repositories or reputable projects, verify checksums, and test in an isolated environment if you have any doubts. A healthy dose of skepticism is a virtue when dealing with third-party code that has full privileges.

It's also advisable to configure sudoers granularly, not relying solely on the sudo group for everything, and to keep logs audited. If you administer servers, check `/var/log/auth.log`, `/var/log/secure`, or `journalctl -xe` to detect misuse. In multi-user environments, knowing who executed each command is key for accountability and compliance with security regulations.

Enable and disable root with a head

If you decide to enable root access, assign a password with `sudo passwd root`, use it only for essential tasks, and then re-lock the account. To disable direct SSH login, edit `sshd_config` and set `PermitRootLogin no` or `prohibit-password`, then restart SSH. To lock the account locally, use `sudo passwd -l root`. To unlock it, use `sudo passwd -u root`. These measures reduce the attack surface and prevent brute-force attacks against the most powerful account.

In most cases, the practical answer to the initial question is yes: you can launch a program from the launcher with root privileges using a graphical helper like kdesu, gksu, gksudo, or pkexec, or by creating a .desktop file with the appropriate command. However, this isn't something you should leave set up for just any application. It's better to have specific administrative launchers with clear names and use them only when necessary.

The key takeaway is that root isn't a toy, and sudo exists precisely to empower you without turning every click into a permanent risk. If you need to launch a graphical app as a superuser, prioritize helpers that require a password, verify that the application truly needs it, and limit its use to administrative tasks. This way, you enjoy the convenience of the launcher without sacrificing the security that makes Linux so strong.