sudo vs gksudo : What are sudo and gksudo and when to use them?

As you may know, sudo is the command that allows you to get root access when running a command that needs it.

Example: sudo apt-get install nmap

Because the normal user is not allowed to install packages, it invokes the root priviledges by sudo and does the job.

gksudo for Gnome or kdesudo for KDE does the same thing as sudo, but for the graphical applications (like gEdit).

You should never use sudo to start graphical apps as root, because some files from your home directory may become owned by root.

For example., if you run sudo nautilus, any files that were created in your home directory will get owned by root. The propper command is gksudo nautilus.

All the gksudo or kdesudo do is setting your HOME=~root and copying .Xauthority to a tmp directory, this preventing files getting owned by root accidentally.

To fix stuff after running sudo nautilus, you have to find all the files owned accidentally by root and set the ownership back to the non root user.

Also, when calling gksudo, you get a graphical box where you insert your password and when using sudo, you are asked to type your password in the terminal, but this is not important at all.

Usually, running sudo for graphical applications does not do any harm, but it is better to know and use kdesudo / gksudo, to prevent bad things, like not being able to log in at all, because of permission issues.

Tagged with: , , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *




Subscribe to get the latest Linux news and how to guides directly on your e-mail!