Unlocking the Power of Linux: A Beginner’s Guide to sudo and pkexec

Kumar Abhinav
2 min readMar 15, 2023

--

Once upon a time, there was a computer user named John who wanted to install some new software on his Linux-based operating system. However, when he tried to do so, he received an error message stating that he did not have sufficient privileges to perform the installation.

John was confused and didn't know what to do. Luckily, his friend Kumar Abhinav, who was an experienced Linux user, was there to help him out. Kumar Abhinav explained to John that there are two common ways to run commands that require administrative privileges in Linux: using sudo and pkexec.

Kumar Abhinav told John that sudo is a command that allows you to temporarily elevate your privileges to that of the root user, who has access to all system resources and can perform any action on the system. By using sudo, John could run commands that require administrative access, such as installing software, modifying system settings, or creating and deleting files in protected directories.

However, Kumar Abhinav also mentioned that pkexec is a more fine-grained approach to privilege escalation. pkexec is typically used by graphical user interfaces (GUIs) to allow users to perform actions that require administrative access. When John ran a program using pkexec, he would be prompted for his password, and if authenticated, the program would be executed with elevated privileges.

Kumar Abhinav explained that pkexec provides an additional layer of security by allowing you to specify a policy file that determines which programs can be run with elevated privileges and by which users. This policy file is typically used by GUIs to restrict access to administrative functions.

John thanked Kumar Abhinav for explaining the differences between sudo and pkexec and decided to use sudo to install his software, as he was more comfortable with it. He successfully installed the software and was happy that he could now use it on his computer.

In the end, John learned that both sudo and pkexec are useful tools for running commands with administrative privileges in Linux, and that choosing which one to use depends on the situation and personal preference.

--

--

Kumar Abhinav
Kumar Abhinav

Written by Kumar Abhinav

My passion for software lies with dreaming up ideas and making them come true with elegant interfaces. I am a 4th year B.Tech (Information Technology) Student.

No responses yet