[LINUX] [tee command] Command for rewriting files that require root privileges as a general user

Status

Trying to rewrite a file with vim as a user without write permission.

Can't open file for writing
Press ENTER or type command to continue

Get angry.

You can switch to the root user and edit again. At that time.

command

:w !sudo tee %

: w! (Save content) sudo tee (write the resulting output to a file as root user) % (Path to the currently loaded buffer file)

Recommended Posts

[tee command] Command for rewriting files that require root privileges as a general user
Enable E-mail login as a custom user that inherits AbstractBaseUser