Score:0

How do I edit hosts files? Lubuntu 20.04

es flag

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?

cn flag
NEVER is "after I change it's permission to 777." the solution so don't use it please. `u do nano /etc/hosts` that is cuz you are missing an `s` in front of `udo`? when using command line use command line tools. `vi`, `vim`, `nano` and not gedit. Using GUI from commandline can alter file properties that should not be changed.
Sandun avatar
jp flag
Did you try opening the file with 'vi' prefix? There you can save any changes by :wq
cn flag
`sudo nano /etc/hosts` should work. so should `sudo vi /etc/hosts` unless you did something that got /etc/hosts removed. does `ls -l /etc/hosts` show the file?
Eric Huelin avatar
es flag
@Nmath I accomplish a site blocking putting 0.0.0.0 to any phishing sites or any malicious site and I have many entries that I put on all my machines.
Eric Huelin avatar
es flag
@sudodus 20.04 Lubuntu "gedit admin:///etc/hosts" this 1 app will ignore the access denied that every other app I tried to use to write to it and couldn't? even so no shortcut added to ddeaktop or start menu so can't access it.
Eric Huelin avatar
es flag
@Rinzwind It's showing, that's not the problem, it's saving and getting any modifications is denied.
Eric Huelin avatar
es flag
@Sandun n00b can't comprehend your question.
Nmath avatar
ng flag
Using hosts for blocking is a bad idea. I am aware there are several (old) guides on the internet advising to do this. Unfortunately, lots of people online share bad advice and it stays there forever even when it becomes outdated. There are better, more effective, and less dangerous ways to block content than manipulating your hosts file with tons of false entries.
Eric Huelin avatar
es flag
@sudodus I don't know how to use it typed "^H" that did nothing.There no save button. Now I tried Ctrl+s, it worked. Realize that no one here suggested how to use "sudo nano /etc/hosts" Windows and OSX have a save button but not Linux. So to me it's a cruel world in Linuxville or the Linux illiterate.
guiverc avatar
cn flag
FYI: `gedit` is the gnome editor; Lubuntu doesn't use GNOME so the LXQt equivalent would be to replace `gedit` with `featherpad`.. but it's not your only option and a GUI editor with `sudo` is not ideal. I'd use `vim` (Lubuntu also includes) but it's a lousy choice for people who aren't familiar with unix.
Score:0
br flag

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.

Eric Huelin avatar
es flag
It's not dangerous if all entries start with 0.0.0.0 it's complimentary to stop mainly malicious websites.
Smile.Hunter avatar
br flag
what if you 0.0.0.0 your software update domain? then you will never get a security patch through auto update, and it can be dangerous.
Eric Huelin avatar
es flag
Linux to me is dangerous to my health. I had to fight and hunt all over the internet waste an entire day just to make Linux behave. How to get file sharing with the host [Solved], How to change screen resolution to 1920x1080 need to run the command line to add resolution every time I start Linux [Not solved], how to edit files that are read only other than hosts [Not solved], how to make desktop shortcuts of files [Not solved] Everything to a Windows and OSX user is hair pulling difficult with Linux. It's jargon heavy needlessly complicated and hostile.
ru flag
@EricHuelin Some of those questions are akin to "How can a non-admin user edit a system file on Windows without getting a UAC prompt?" - it's permissions separation, not rocket science. The 'jargon' has a ton of synonyms across the universe. "Shortcuts" are called symlinks. and for OS X it's actually a LOT of Linux jargon too ;)
Eric Huelin avatar
es flag
@Thomas Ward Difference is Linux is more jargon dependent, I never met a distro where you don't ever have to type sudo. Most answers requires using the terminal. I even wanted desktop shortcuts and I get argued with "it's only typing 10 character in the terminal why would you want a desktop shortcut?" Frustrating geek mentality.
ru flag
@EricHuelin I fail to see that here, my suggestion is you save your complaints about jargon, etc. for social media, not here.
Eric Huelin avatar
es flag
@Thomas Ward I promise to not ask any questions here about how annoying Linux is.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.