Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've been using gksudo nautilus and sudo nautilus through Alt+F2.

What's the difference? They look very similar!

share|improve this question
    
Related: Why is gksu no longer installed by default? –  Aditya Mar 20 at 17:08

9 Answers 9

up vote 63 down vote accepted

Taken from here:

You should never use normal sudo to start graphical applications as root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=/root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by root.

Please note that this is primarily about configuration files. If you run Nautilus as root, even with gksu/gksudo, and you create a file or folder anywhere with it (including in your home directory), that file or folder will be owned by root. But if you run Nautilus (or most other graphical applications) as root with sudo, they may save their configuration files in your home directory (rather than root's home directory). Those configuration files may be owned by root and inaccessible when you're not running as root, which can severely mess up your settings, and may even keep some applications from working altogether.

The solution, once you have made this mistake, is to find the configuration files and delete them or chown them back to belonging your non-root user. Many such files start with a . or are contained in a directory that starts with a .. Some are located inside the .config folder in your home directory. To see files and folders that start with a . in Nautilus, press Ctrl+H (this shows hidden files.) To see them with ls, use the -a (or -A) flag.

To find if there are files not owned by you in your home directory, you can use the following command in a terminal:

find $HOME -not -user $USER -exec ls -lad {} \;

which will list all files under the home directory not owned by the user.

share|improve this answer
    
I've already used 'sudo nautilus'. That means that my home directory is now owned by root? (PS: my English is not perfect) –  DrKenobi Nov 6 '10 at 22:41
16  
No, it means that while you were running Nautilus as root, any files that it created in your home directory will be owned by root. This could include thumbnails and other supporting files that Nautilus creates automatically. –  Ryan Thompson Nov 6 '10 at 23:03
    
OK, Great! Thank you Ryan Thompson! –  DrKenobi Nov 7 '10 at 0:26
1  
. The quoted segemnet you used has puzzled me since I first read it; specifically where it says: "This prevents files in your home directory becoming owned by root." .. I tested this today by creating some test files, on 10.04, 10.04(VM), 10.10(VM), and no matter how I started sudo/gksudo (Terminal->Nautilus, Terminal->gedit, Alt+F2...)... all cases caused my newly created to be owned by "root", with group "root".. Maybe I've missed something but I think that part of the quoted segment is misleading people... –  Peter.O Jan 6 '11 at 9:04
2  
@Peter.O I've expanded this answer to address that question and explain exactly which files are treated differently with sudo, via gksu/gksudo. (@ChrisWilson Feel free to roll back or shorten this edit if you feel it's not totally within the scope of your answer...it seems to me it is, but that's entirely your call.) –  Eliah Kagan Jul 15 '12 at 16:34

Did you know there is a Nautilus add on called nautilus-gksu Install nautilus-gksu which adds an "open as administrator" to nautilus' right click menu?

Note: Not available in Ubuntu 12.04 and onward.

share|improve this answer
    
nautilus-gksu is no longer available from Ubuntu 12.04 and onward. –  IQAndreas Jul 14 '13 at 21:39
    
And your link only shows that it is available up to 11.10... –  Wilf Dec 15 '13 at 18:02

If you start a graphical application with sudo you can mess up the ownership of your files which can cause your apps to break. Never do that. Check the Community Help:

You should never use normal sudo to start graphical applications as Root. You should use gksudo (kdesudo on Kubuntu) to run such programs. gksudo sets HOME=~root, and copies .Xauthority to a tmp directory. This prevents files in your home directory becoming owned by Root. (AFAICT, this is all that's special about the environment of the started process with gksudo vs. sudo).

share|improve this answer

you can also select and add a script inside Nautilus "open as administrator", If you do that you can right click and open as root.

share|improve this answer
    
A link to how to add such a script in 12.04: How To Add Open As Administrator In Ubuntu 12.04 –  James Jul 28 '12 at 15:56

sudo by default preserves your $HOME variable. For example, if you run sudo firefox you will run with root privileges but your configuration. If you change settings in this situation, you will end up with parts of your configuration owned by root instead of your user id.

share|improve this answer

you can have a look here

share|improve this answer
14  
Please, don't answer with a plain link, but always with a summary/excerpt from the place you are linking! –  Peter Smit Nov 6 '10 at 16:21

a very helpful explanation / discussion including many screenshots: http://psychocats.net/ubuntu/graphicalsudo

share|improve this answer

If you choose gksudo nautilus, You ask your password graphically. With sudo, you ask it in a terminal

share|improve this answer
3  
That's not the only difference, and often is not the most important difference. (See some of the other answers here.) –  Eliah Kagan Jul 15 '12 at 16:34

Found in the file generated by the terminal command 'info gksudo': "gksu is a front-end to su and gksudo is a front-end to sudo. Their primary purpose is to run graphical commands that need root without the need to run an X terminal emulator and using su directly."

I have found that, in many cases, the 'info' files have helpful descriptions as well as useful information on options. I would strongly suggest that learning about any command first start with accessing the 'info' file on that command.

For the beginner, in the terminal, type or paste the command info with the command name in which you are interested as a parameter. The format is :~$ info [command_name] (remember not to include the command prompt or the brackets). Suggested terminal entries for the beginner are:

:~$ info

:~$ info info

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.