A reminder about the proper way to invoke root in Ubuntu

ubuntu.png

I’ve been answering a lot of support threads lately wherein users have said they are unable to empty the trash can because a file in there is owned by root or they cannot get a Firefox setting change to stick (and it turns out their Firefox settings folder is owned by root).

Do you know where this comes from, why this is happening?

Bad advice. It all comes from bad advice.

The follow hopes to counter that.

A persistent root terminal prompt
If you want a persistent root command-line instead of typing sudo for a series of commands, the proper way to get this persistent root is the command

Code:
sudo -i

It is not the command sudo -s.

The difference is that

Code:
sudo -i

will log you in as root and use root’s environment, and sudo -s will log you in as root and use the user environment. That means, if you use sudo -s, the changes you’re making will be made with root powers but affect your user folder. This is bad. You don’t want this.

Graphical root
If you want to launch a graphical application as root, use

Code:
gksudo nautilus

or

Code:
kdesu konqueror

or (if you’re using Mozilla’s Firefox and need to update)

Code:
gksudo firefox

Do not use the commands sudo nautilus or sudo konqueror or sudo firefox.

Same deal as sudo -i and sudo -s here. If you run a graphical application with sudo instead of gksudo or kdesu, you’ll be running the application as root but with the user’s environment. That means when you move something to the trash, you’ll move it to the trash as root, but it’ll go into the user’s trash. That means if you touch a Firefox setting, it’ll be touched as root but will affect the user’s Firefox setting.

Other stuff
Yes, I am in the habit of using gksudo, but I know it’s a symlink to gksu. If you want to save yourself typing two letters, you can use gksu instead of gksudo.

gksudo is for GTK applications. You use gksudo mainly if you’re using Ubuntu or Xubuntu.

kdesu is for QT applications. You use kdesu mainly if you’re using Kubuntu.

Source

Related Posts

Comments are closed.