How Do I Edit Hosts Files? Lubuntu 20.04

Normally I get a access denied even after I change it's permission to 777.

I see many solutions

Use gedit, dunno how to get use or find whatever that is.

Other solutions use the terminal sudo -i gedit /etc/hosts Sure but I don't know how to save a file from the terminal, CTRL+D does nothing.

Try sudo nano /etc/hosts I get: No such file or directory

Try the this program: hostsed but it is also denied me to save.

So how do I edit and save my hosts file?

10

1 Answer

First, backup your hosts file.

cp /etc/hosts ~/Desktop/hosts.ori

Then, mess up with it using sudo to get the right permission, follow by your choice of text editor, such as nano or vim.

sudo vim /etc/hosts
sudo nano /etc/hosts

hosts file modification can be dangerous as it allows to poison DNS queries with malicious servers. For example, a malicious actor may edit your hosts file to forward your passwords to their servers!! Play with it at your own risk.

7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest