MediumHow to Edit Root Owned Files on Linux Without Running Your Editor as Root | by Sabit | Bash_DevOps_AI | Nov, 2026 | Medium
Sitemap
Bash_DevOps_AI

Practical Linux, terminal tricks, and AI engineering for people learning the hard way. No fluff. No assumed knowledge. Just the commands, concepts, and honest lessons from someone building in public. New articles every week.

Member-only story

How to Edit Root Owned Files on Linux Without Running Your Editor as Root

7 min read4 days ago

--

Press enter or click to view image in full size
Photo by Jason Ng on Unsplash

You need to change one line in /etc/hosts. You open it in your editor. You make the edit. You try to save.

E212: Can't open file for writing

The file belongs to root. A normal user cannot write to it. You do what everyone does. You press Up and put sudo in front of the same command. The editor opens again and this time you can save.

It works. It also quietly breaks a safety rule. You just started a large and complicated program with full administrator rights. Linux has a better way. A single command lets you edit protected files while your editor runs as you. The command is sudoedit.

Why You Get Permission Denied

Every file on Linux has an owner and a set of permissions. Look at the hosts file.

ls -l /etc/hosts
-rw-r--r-- 1 root root 221 Oct 29 09:10 /etc/hosts

The first column shows the permissions. The third column names the owner. Here the owner is root. The letters rw- in the first group mean the owner can read and write. The next two groups show r--. Everyone else can only read.

--

--

Sabit
Sabit

Written by Sabit

Learning AI engineering from zero. Building as I go. Terminal Academy: https://terminalacademy.uk. Practical guide for business owners: chosennotcompared.uk

Bash_DevOps_AI
Bash_DevOps_AI

Published in Bash_DevOps_AI

Practical Linux, terminal tricks, and AI engineering for people learning the hard way. No fluff. No assumed knowledge. Just the commands, concepts, and honest lessons from someone building in public. New articles every week.