Sudoedit
lastmod 2023-07-21created 2023-07-211 edits
sudoedit vs sudo vim
sudoedit specifies sudo with the -e option. From the man page:
-e The -e (edit) option indicates that, instead of running a command, the
user wishes to edit one or more files. In lieu of a command, the string
"sudoedit" is used when consulting the security policy. If the user is
authorized by the policy, the following steps are taken.
So a system administrator can allow sudo privileges only for editing specific files, rather than for specific commands or for all files in general. This lets the administrator control which files a user (or group of users) can edit with elevated privileges.
Users can also keep using their preferred editor rather than one specified by the administrator.
It also runs that editor as the user themselves. This means that, for example, any options or commands the user has specified in .vimrc apply.