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.

If I run the following command, the text file opens in my preferred editor (kate).

$ xdg-open /path/to/text/file

However, if I try the following, where sparhawk is my username, I get several warnings, and the file opens in Chromium instead.

$ sudo -u sparhawk xdg-open /path/to/text/file
Warning: unknown mime-type for "/path/to/text/file" -- using "application/octet-stream"
Error: no "view" mailcap rules found for type "application/octet-stream"
Opening "/path/to/text/file" with notepad  (text/plain)
wine: invalid directory "/home/sparhawk/.wine" in WINEPREFIX: not an absolute path
Created new window in existing browser session.

What is the difference?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

One needs to "simulate initial login" with the -i flag. Hence,

$ sudo -i -u sparhawk xdg-open /path/to/text/file
share|improve this answer
add comment

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.