is vim safe to use in combination with sudo
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
It is not advisable to use sudo
with a graphical application like gedit
, as described at this link. Accordingly, I have tended to use vim
with sudo
.
Recently I noticed my ~/.viminfo
was owned by root on a fairly fresh install of 16.04 (xenial) so it had me wondering if even vim
is considered to be graphical or if there is some other problem with invoking sudo vim
. After changing ownership to myself via:
sudo find $HOME -not -user $USER -exec chown $USER:$(id -g) +
and subsequently running sudo vim
I was unable to have ~/.viminfo
owned by root, however, I am certain that it recently was owned by root.
Is it unadvisable to invoke sudo vim
?
sudo vim
add a comment |Â
up vote
1
down vote
favorite
It is not advisable to use sudo
with a graphical application like gedit
, as described at this link. Accordingly, I have tended to use vim
with sudo
.
Recently I noticed my ~/.viminfo
was owned by root on a fairly fresh install of 16.04 (xenial) so it had me wondering if even vim
is considered to be graphical or if there is some other problem with invoking sudo vim
. After changing ownership to myself via:
sudo find $HOME -not -user $USER -exec chown $USER:$(id -g) +
and subsequently running sudo vim
I was unable to have ~/.viminfo
owned by root, however, I am certain that it recently was owned by root.
Is it unadvisable to invoke sudo vim
?
sudo vim
Some related questions: unix.stackexchange.com/q/134500/103151 - superuser.com/q/1221102/418736 - askubuntu.com/q/211346/367990
â Byte Commander
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
It is not advisable to use sudo
with a graphical application like gedit
, as described at this link. Accordingly, I have tended to use vim
with sudo
.
Recently I noticed my ~/.viminfo
was owned by root on a fairly fresh install of 16.04 (xenial) so it had me wondering if even vim
is considered to be graphical or if there is some other problem with invoking sudo vim
. After changing ownership to myself via:
sudo find $HOME -not -user $USER -exec chown $USER:$(id -g) +
and subsequently running sudo vim
I was unable to have ~/.viminfo
owned by root, however, I am certain that it recently was owned by root.
Is it unadvisable to invoke sudo vim
?
sudo vim
It is not advisable to use sudo
with a graphical application like gedit
, as described at this link. Accordingly, I have tended to use vim
with sudo
.
Recently I noticed my ~/.viminfo
was owned by root on a fairly fresh install of 16.04 (xenial) so it had me wondering if even vim
is considered to be graphical or if there is some other problem with invoking sudo vim
. After changing ownership to myself via:
sudo find $HOME -not -user $USER -exec chown $USER:$(id -g) +
and subsequently running sudo vim
I was unable to have ~/.viminfo
owned by root, however, I am certain that it recently was owned by root.
Is it unadvisable to invoke sudo vim
?
sudo vim
sudo vim
asked 1 hour ago
H2ONaCl
3,047204783
3,047204783
Some related questions: unix.stackexchange.com/q/134500/103151 - superuser.com/q/1221102/418736 - askubuntu.com/q/211346/367990
â Byte Commander
1 hour ago
add a comment |Â
Some related questions: unix.stackexchange.com/q/134500/103151 - superuser.com/q/1221102/418736 - askubuntu.com/q/211346/367990
â Byte Commander
1 hour ago
Some related questions: unix.stackexchange.com/q/134500/103151 - superuser.com/q/1221102/418736 - askubuntu.com/q/211346/367990
â Byte Commander
1 hour ago
Some related questions: unix.stackexchange.com/q/134500/103151 - superuser.com/q/1221102/418736 - askubuntu.com/q/211346/367990
â Byte Commander
1 hour ago
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
Yes, it is safe.
The problem with sudo gedit
is because GUI apps use certain files such as ~/.cache/dconf
and after elevated gedit
that file becomes root-owned. Well, that particular file contains user-specific settings for GUI apps, including desktop, so if the system can't read those settings - it's bad. IIRC user can't start particular desktop. User's recent files data recently-used.xbel
also gets affected.
On the other hand, vim
doesn't have that problem. It uses no GUI-related database, and doesn't put anything into recently-used.xbel
. It was created for console-only purpose, although gVim also exists. In fact, on some systems vim
is your only choice of editor. So it is safer than gedit
by virtue of not causing same problems. You're still editing as root in both cases, so you could cause problems with improper editing.
According to this blog :
The first time you use vim, the file '~/.viminfo' is created, and if you use 'sudo vim' the first time you use vim after installing it on a fresh system, the permissions on ~/.viminfo will have the owner set to root instead of the default user.
While author points out it can lead to issue, there's nothing complex - just chown
the file back to yourself.
See also:
- What specific bad things happen when gedit is used with sudo?
add a comment |Â
up vote
1
down vote
It's fine to use vi as root. There's going to be times when you need to edit a file that requires sudo or root privileges, like changing your network interfaces file, or maybe editing your sshd config file. Using root for graphical stuff is bad because people would connect to IRC or browse the web as root. If they got a virus while doing so, it would have full root access.
add a comment |Â
up vote
1
down vote
The link is very old (2013). It recommends using gksudo
or gksu
for graphical applications but both of those are becoming obsolete. Later on the accepted answer also suggests sudo -H
though.
The general consensus in the Ask Ubuntu community recently is to use:
sudo -H gedit /path/to/filename
The only problem remains that sudo
doesn't have a profile for tab settings, extensions, word wrap, font name, font size, etc. You can inherit these from your user profile though with a wrapper script like this: How can I sync my root gedit with my user gedit's preferences?
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Yes, it is safe.
The problem with sudo gedit
is because GUI apps use certain files such as ~/.cache/dconf
and after elevated gedit
that file becomes root-owned. Well, that particular file contains user-specific settings for GUI apps, including desktop, so if the system can't read those settings - it's bad. IIRC user can't start particular desktop. User's recent files data recently-used.xbel
also gets affected.
On the other hand, vim
doesn't have that problem. It uses no GUI-related database, and doesn't put anything into recently-used.xbel
. It was created for console-only purpose, although gVim also exists. In fact, on some systems vim
is your only choice of editor. So it is safer than gedit
by virtue of not causing same problems. You're still editing as root in both cases, so you could cause problems with improper editing.
According to this blog :
The first time you use vim, the file '~/.viminfo' is created, and if you use 'sudo vim' the first time you use vim after installing it on a fresh system, the permissions on ~/.viminfo will have the owner set to root instead of the default user.
While author points out it can lead to issue, there's nothing complex - just chown
the file back to yourself.
See also:
- What specific bad things happen when gedit is used with sudo?
add a comment |Â
up vote
1
down vote
accepted
Yes, it is safe.
The problem with sudo gedit
is because GUI apps use certain files such as ~/.cache/dconf
and after elevated gedit
that file becomes root-owned. Well, that particular file contains user-specific settings for GUI apps, including desktop, so if the system can't read those settings - it's bad. IIRC user can't start particular desktop. User's recent files data recently-used.xbel
also gets affected.
On the other hand, vim
doesn't have that problem. It uses no GUI-related database, and doesn't put anything into recently-used.xbel
. It was created for console-only purpose, although gVim also exists. In fact, on some systems vim
is your only choice of editor. So it is safer than gedit
by virtue of not causing same problems. You're still editing as root in both cases, so you could cause problems with improper editing.
According to this blog :
The first time you use vim, the file '~/.viminfo' is created, and if you use 'sudo vim' the first time you use vim after installing it on a fresh system, the permissions on ~/.viminfo will have the owner set to root instead of the default user.
While author points out it can lead to issue, there's nothing complex - just chown
the file back to yourself.
See also:
- What specific bad things happen when gedit is used with sudo?
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Yes, it is safe.
The problem with sudo gedit
is because GUI apps use certain files such as ~/.cache/dconf
and after elevated gedit
that file becomes root-owned. Well, that particular file contains user-specific settings for GUI apps, including desktop, so if the system can't read those settings - it's bad. IIRC user can't start particular desktop. User's recent files data recently-used.xbel
also gets affected.
On the other hand, vim
doesn't have that problem. It uses no GUI-related database, and doesn't put anything into recently-used.xbel
. It was created for console-only purpose, although gVim also exists. In fact, on some systems vim
is your only choice of editor. So it is safer than gedit
by virtue of not causing same problems. You're still editing as root in both cases, so you could cause problems with improper editing.
According to this blog :
The first time you use vim, the file '~/.viminfo' is created, and if you use 'sudo vim' the first time you use vim after installing it on a fresh system, the permissions on ~/.viminfo will have the owner set to root instead of the default user.
While author points out it can lead to issue, there's nothing complex - just chown
the file back to yourself.
See also:
- What specific bad things happen when gedit is used with sudo?
Yes, it is safe.
The problem with sudo gedit
is because GUI apps use certain files such as ~/.cache/dconf
and after elevated gedit
that file becomes root-owned. Well, that particular file contains user-specific settings for GUI apps, including desktop, so if the system can't read those settings - it's bad. IIRC user can't start particular desktop. User's recent files data recently-used.xbel
also gets affected.
On the other hand, vim
doesn't have that problem. It uses no GUI-related database, and doesn't put anything into recently-used.xbel
. It was created for console-only purpose, although gVim also exists. In fact, on some systems vim
is your only choice of editor. So it is safer than gedit
by virtue of not causing same problems. You're still editing as root in both cases, so you could cause problems with improper editing.
According to this blog :
The first time you use vim, the file '~/.viminfo' is created, and if you use 'sudo vim' the first time you use vim after installing it on a fresh system, the permissions on ~/.viminfo will have the owner set to root instead of the default user.
While author points out it can lead to issue, there's nothing complex - just chown
the file back to yourself.
See also:
- What specific bad things happen when gedit is used with sudo?
answered 51 mins ago
Sergiy Kolodyazhnyy
67.2k9136299
67.2k9136299
add a comment |Â
add a comment |Â
up vote
1
down vote
It's fine to use vi as root. There's going to be times when you need to edit a file that requires sudo or root privileges, like changing your network interfaces file, or maybe editing your sshd config file. Using root for graphical stuff is bad because people would connect to IRC or browse the web as root. If they got a virus while doing so, it would have full root access.
add a comment |Â
up vote
1
down vote
It's fine to use vi as root. There's going to be times when you need to edit a file that requires sudo or root privileges, like changing your network interfaces file, or maybe editing your sshd config file. Using root for graphical stuff is bad because people would connect to IRC or browse the web as root. If they got a virus while doing so, it would have full root access.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
It's fine to use vi as root. There's going to be times when you need to edit a file that requires sudo or root privileges, like changing your network interfaces file, or maybe editing your sshd config file. Using root for graphical stuff is bad because people would connect to IRC or browse the web as root. If they got a virus while doing so, it would have full root access.
It's fine to use vi as root. There's going to be times when you need to edit a file that requires sudo or root privileges, like changing your network interfaces file, or maybe editing your sshd config file. Using root for graphical stuff is bad because people would connect to IRC or browse the web as root. If they got a virus while doing so, it would have full root access.
answered 1 hour ago
The Letter M
1314
1314
add a comment |Â
add a comment |Â
up vote
1
down vote
The link is very old (2013). It recommends using gksudo
or gksu
for graphical applications but both of those are becoming obsolete. Later on the accepted answer also suggests sudo -H
though.
The general consensus in the Ask Ubuntu community recently is to use:
sudo -H gedit /path/to/filename
The only problem remains that sudo
doesn't have a profile for tab settings, extensions, word wrap, font name, font size, etc. You can inherit these from your user profile though with a wrapper script like this: How can I sync my root gedit with my user gedit's preferences?
add a comment |Â
up vote
1
down vote
The link is very old (2013). It recommends using gksudo
or gksu
for graphical applications but both of those are becoming obsolete. Later on the accepted answer also suggests sudo -H
though.
The general consensus in the Ask Ubuntu community recently is to use:
sudo -H gedit /path/to/filename
The only problem remains that sudo
doesn't have a profile for tab settings, extensions, word wrap, font name, font size, etc. You can inherit these from your user profile though with a wrapper script like this: How can I sync my root gedit with my user gedit's preferences?
add a comment |Â
up vote
1
down vote
up vote
1
down vote
The link is very old (2013). It recommends using gksudo
or gksu
for graphical applications but both of those are becoming obsolete. Later on the accepted answer also suggests sudo -H
though.
The general consensus in the Ask Ubuntu community recently is to use:
sudo -H gedit /path/to/filename
The only problem remains that sudo
doesn't have a profile for tab settings, extensions, word wrap, font name, font size, etc. You can inherit these from your user profile though with a wrapper script like this: How can I sync my root gedit with my user gedit's preferences?
The link is very old (2013). It recommends using gksudo
or gksu
for graphical applications but both of those are becoming obsolete. Later on the accepted answer also suggests sudo -H
though.
The general consensus in the Ask Ubuntu community recently is to use:
sudo -H gedit /path/to/filename
The only problem remains that sudo
doesn't have a profile for tab settings, extensions, word wrap, font name, font size, etc. You can inherit these from your user profile though with a wrapper script like this: How can I sync my root gedit with my user gedit's preferences?
answered 9 mins ago
WinEunuuchs2Unix
38.6k1060144
38.6k1060144
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1090632%2fis-vim-safe-to-use-in-combination-with-sudo%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Some related questions: unix.stackexchange.com/q/134500/103151 - superuser.com/q/1221102/418736 - askubuntu.com/q/211346/367990
â Byte Commander
1 hour ago