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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like