0

If I needed to run a graphical command as root, I would use:

username@HENRY-PC:~$ sudo gedit
[sudo] password for username: 

But this is apparently discouraged, because any files created for the X-server in my home folder, would be owned by root. It is recommended that I use gksu. My problem is that when I use gksu, it freezes my display, opens a overlay, then asks for my password. This interrupts me while multitasking.

According to this: askubuntu.com/questions/11760, the configuration files will be saved as root in my home directory, this is what I don't want, and gksu will set the home directory to root, so the configuration files will be saved there. I know any files that I create will be saved as root.

How would I change gksu to ask for password in the commandline instead?

2
  • You effectively don't. If you need to run it from root, you can, and then run a sudo chown later to change file ownership. gksu operates under the same logic as sudo does, as well, in that anything 'created' by the application will be done as the superuser root.
    – Thomas Ward
    Mar 29 '15 at 1:02
  • According to this: askubuntu.com/questions/11760, the configurations files will be saved as root. I know that the created files will be saved a root, but how would I prevent the configurations files from being saved as root.
    – Henry
    Mar 29 '15 at 2:13
0

You can use sudo -H gedit instead. From man sudo:

 -H, --set-home
             Request that the security policy set the HOME environment
             variable to the home directory specified by the target user's
             password database entry.  Depending on the policy, this may
             be the default behavior.

AFAIK this request is honored on modern Ubuntu systems, and should have the same effect as gksudo or gksu.

4
  • What about making gksu asking for password in command line.
    – Henry
    Mar 29 '15 at 4:33
  • sudo -H echo $HOME gives /home/username, instead of /root. sudo -i followed by echo $HOME gives /root
    – Henry
    Mar 29 '15 at 15:09
  • Nevermind, sudo -H bash -c 'echo $HOME' gives the intended result (/root).
    – Henry
    Mar 29 '15 at 15:11
  • @Henry yes that's because in your first command $HOME gets expanded by the current shell. Mar 29 '15 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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