When it comes to computers and the internet there are several incredibly important things that most people don't either don't realize of chose to ignore. First is the fact that the internet is quite a dangerous place for several reasons. One dangeous thing that most people think of on the internet are viruses, I can tell you as someone who knows a thing or two about this stuff that there is really no reason for anyone to worry about computer viruses in 2020 and if you are paying for an antivirus service you are wasting your money, Windows 10 comes with some pretty good antivirus software already, Mac OS is set up in such a way that it is incredibly hard for a virus to run on it without you knowing about it and Linux is Linux.* So viruses are not what I want to talk about.
The dangerous things on the internet I'd like to talk about today are ads, trackers, and porn. Ads are dangerous because their goal is to get you to spend money on something you don't need, but they also can considerably slow down your browsing experience, (see this piece I wrote) and they have the potential to carry viruses (just because you don't need antivirus software doesn't mean you shouldn't watch out). Tracking is dangerous because nobody wants any company or government to be keeping logs of everything they're doing. And if you don't understand why porn is dangerous your parents failed you. Luckily it is quite easy to prevent your computer from being able to access any of these things. And this method is not thrugh some sketchy browser extension or some intrusive third party program, it is done by taking advantage of a powerful core feature of your operating system.
Now before I teach you how to do this I'd like to teach you how accessing sites on the internet work so that you can understand why blocking things this way is the absolute most effective way to block anything on your computer, and also becasue I'm a computer science student and this almost useless information thats been put in my head has to be used somehow.
You navigate through the internet through URLs like the one for this page: https://jacobwsmith.xyz/guides/block_junk.html all a serch engine does is give you a list of relevant URLs and all a link is is a URL. I don't remember what URL stands for but that doesn't really matter right now. URLs have three major parts, the protocol, a domain name, and a file path. The protocol in the above URL is https, all you really need to know about that is that if it is https rather than http then you can ignore 95% of what VPN commercials tell you.** The file path in a URL is just as it sounds, its the location of the file you are accessing on the server the site is hosted on. The domain name (jacobwsmith.xyz in this case) is what is important to this discussion.
If you are going to your friend Donald's house you are not going to tell your mom that you are going to 1600 Pennsylvania Ave NW, Washington, DC 20500-0003, United States, you are going to tell her that you're going to go to Donald's house. Domain names work much the same way, they translate one easy to remember thing to an address which is harder to remember. In the context of the above example "Donald's house" acts as the domain name while his address is, well, his address. In the correct context of the internet jacobwsmith.xyz translates to my server's IP address 126.96.36.199. When going to a new page your browser, using the protocol specified in the URL you gave it, will ask the server whose IP address belongs to the URL's domain name for access to the file specified by the file path.
Now, how do domain names translate to IP addresses you might ask. Well domain name and IP address pairnings are stored on at least one DNS (Domain Name System) server. There are a few dozen of these around the world and I spend like ten bucks a year to keep my domain name registered in them. When you have your browser go to a new site your browser will first ask a DNS server what IP address the domain name corresponds to and only after your browser gets that info back it can request access to youir desired site. If your computer gets the right IP address back then you get the right site.
Now understanding how domain names work is great but how does that relate to blocking porn? Well it turns out that a DNS server is not the first place your computer checks when it is looking for an IP address, it first checks your hosts file. Your hosts file is a file stored locally on your computer which does the exact same thing that a DNS server does exept it only contains the domain name and IP address pairings that you put on it, and you can pair any domain name with any IP address you want, including 0.0.0.0 the null address. If a domain name that your brower is trying to access exists in your hosts file then your computer will not request the actual domain name from a DNS server, it will just go to whatever address you specified, if you specified the null address then your brower will go nowhere.
On a unix based operating system the hosts file is located at /etc/hosts on Windows it is at c:\windows\system32\drivers\etc\hosts (you may actually have to create this file in some cases) regardless of what operating system you are on you will need administrative privileges to access and edit your hosts file so you probably won't be able to prank anyone with this trick.
Once you've opened your hosts file the question becomes what now, there are literally thousands of domain names which point to ad services, tracking, and porn, you're not going to type every single one out to block, luckily you don't have to plenty of other people already have. The blocklist I use can be found here It has over 40,000 tracking and ad domains, like 8,000 porn sites and a thousand or so other sites that you shouldn't be using. I didn't put that list toghether and I'm pretty sure the guy I got that from didn't either. There may be a few sites on there that you might not want to block (for example some people think using Google*** or Facebook is a good idea) if you want to unblock a domain name just delete the line it's on or put a # in front of it (most of the stuff you might actually want are twards the bottom of the list so they're easier to find).
I hope you realize that you really have a lot of power over what your computer can do, depending on your operating system that power is shrinking, but you still have a lot of power. Learn about it and use it for the benefit of you and others.
* Here is a good video explaining why antivirus software is a scam
** Yes VPNs are a waste of money too
Stuff like Google Drive and YouTube aren't bloked on that list
Note that this sort of thing is also possible to do over a whole Wi-Fi network, I don't know how to do it because I don't own a router.