-1

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?

  • 1
    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. – Rinzwind Jul 27 '21 at 19:27
  • Did you try opening the file with 'vi' prefix? There you can save any changes by :wq – Sandun Jul 27 '21 at 19:28
  • 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? – Rinzwind Jul 27 '21 at 19:28
  • 1
    @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 Jul 27 '21 at 20:24
  • @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 Jul 27 '21 at 20:36
  • @Rinzwind It's showing, that's not the problem, it's saving and getting any modifications is denied. – Eric Huelin Jul 27 '21 at 20:38
  • @Sandun n00b can't comprehend your question. – Eric Huelin Jul 27 '21 at 20:40
  • 2
    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. – Nmath Jul 27 '21 at 20:44
  • @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. – Eric Huelin Jul 27 '21 at 21:09
  • 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. – guiverc Jul 27 '21 at 22:32

1 Answers1

0

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.

Smile.Hunter
  • 8,365
  • It's not dangerous if all entries start with 0.0.0.0 it's complimentary to stop mainly malicious websites. – Eric Huelin Jul 27 '21 at 20:44
  • 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. – Smile.Hunter Jul 27 '21 at 20:51
  • 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. – Eric Huelin Jul 27 '21 at 21:27
  • @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 ;) – Thomas Ward Jul 28 '21 at 00:45
  • @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. – Eric Huelin Jul 28 '21 at 08:25
  • @EricHuelin I fail to see that here, my suggestion is you save your complaints about jargon, etc. for social media, not here. – Thomas Ward Jul 28 '21 at 13:55
  • @Thomas Ward I promise to not ask any questions here about how annoying Linux is. – Eric Huelin Jul 28 '21 at 14:22