
In the world of Ubuntu 18.04, the once-popular gksu
command has been deprecated. This has left many users wondering how to run Graphical User Interface (GUI) applications as the root user. In this article, we will explore the alternatives to gksu
and how to use them effectively.
To replace gksu in Ubuntu 18.04 and run GUI applications as root, you can use the sudo -H command or pkexec. These alternatives provide a safer way to elevate permissions for graphical applications. Additionally, you can create desktop files with sudo -H or pkexec commands for frequently used applications.
Understanding the Deprecation of gksu
The gksu
command was a staple in previous versions of Ubuntu for running GUI applications with root permissions. However, due to potential security risks, gksu
has been removed from Ubuntu 18.04 and many other Linux distributions.
Running graphical applications as root is generally discouraged due to these security risks. However, there are situations where it may be necessary, and Ubuntu has provided alternative methods to achieve this.
Using sudo -H
One of the alternatives to gksu
is using the sudo
command with the -H
flag. The -H
flag stands for HOME, and it ensures that the application is run with the environment variables of the target user (in this case, root).
To use this method, you would type sudo -H
followed by the name of the application you wish to run as root. For example, to run the Gedit text editor as root, you would use the following command:
sudo -H gedit
This command will prompt you for your password and then run Gedit with root permissions.
Using pkexec
Another alternative to gksu
is pkexec
, which is part of the Polkit software. pkexec
allows an authorized user to execute program as another user. However, pkexec
requires a policy file to be created for each application that you want to run as root.
To use pkexec
, you would type pkexec
followed by the name of the application. For example, to run Nautilus file manager as root, you would use the following command:
pkexec nautilus
This command will prompt you for your password and then run Nautilus with root permissions.
Creating Desktop Files
For applications that you frequently run as root, you can create a desktop file that uses either sudo -H
or pkexec
to start the application. The desktop file should be placed in the ~/.local/share/applications/
directory.
Here is an example of a desktop file for Gedit:
[Desktop Entry]
Name=Gedit (as root)
Exec=sudo -H gedit
Icon=gedit
Type=Application
Categories=Utility;TextEditor;
This desktop file will add a new entry to your application menu for Gedit (as root). When you select this entry, it will prompt you for your password and then run Gedit with root permissions.
Conclusion
While the deprecation of gksu
in Ubuntu 18.04 may seem inconvenient, the alternatives provided by Ubuntu offer a safer way to run GUI applications with elevated permissions. Whether you choose to use sudo -H
, pkexec
, or create desktop files, these methods provide the flexibility and security needed to run GUI applications as root.
gksu
was deprecated in Ubuntu 18.04 due to security risks associated with running graphical applications as root. It is generally discouraged to run GUI applications with root permissions as it can pose a threat to the system’s security.
Yes, you can still run GUI applications as root in Ubuntu 18.04. There are alternative methods available such as using sudo -H
or pkexec
to run applications with elevated permissions.
To run a GUI application as root using sudo -H
, you need to open a terminal and type sudo -H
followed by the name of the application. For example, to run Gedit as root, you would use the command sudo -H gedit
. It will prompt you for your password and then run the application with root permissions.
pkexec
is a command-line utility that allows an authorized user to execute programs as another user, typically with root privileges. It requires a policy file to be created for each application you want to run as root. To use pkexec
, open a terminal and type pkexec
followed by the name of the application. For example, to run Nautilus as root, you would use the command pkexec nautilus
. It will prompt you for your password and then run the application with root permissions.
To create a desktop file to run a GUI application as root, you need to create a text file with a .desktop
extension in the ~/.local/share/applications/
directory. In the file, specify the name, executable command (using sudo -H
or pkexec
), icon, type, and categories. Save the file and it will add a new entry to your application menu, allowing you to run the application as root with a click.
Running GUI applications as root is generally discouraged due to the potential security risks involved. It is recommended to use root privileges sparingly and only when necessary. It is important to exercise caution and be aware of the potential risks associated with running applications with elevated permissions.